0

I have an array

Array
(
    [0] => Array
        (
            [0] => 96
            [1] => ML based
            [7] => Open
        )

)
Array
(
    [0] => Array
        (
            [0] => 97
            [1] => Application 
            [7] => Open
        )

)
Array
(
    [0] => Array
        (
            [0] => 98
        )

)
Array
(
    [0] => Array
        (
            [0] => 99
        )

)

I want to remove

Array
(
    [0] => Array
        (
            [0] => 98
        )

)
Array
(
    [0] => Array
        (
            [0] => 99
        )

)

from this array

I tried:

$data = array_map('array_filter', $rowData);
unset($data[0][0]); 

Expected output:

Array
(
[0] => Array
    (
        [0] => 96
        [1] => ML based )
        [7] => Open
    )

)
Array
(
[0] => Array
    (
        [0] => 97
        [1] => Application 
        [7] => Open
    )

)

any help would be Appreciated .

2
  • So you want the array with single element to be removed, right? Commented Aug 28, 2018 at 7:14
  • @SougataBose yes Commented Aug 28, 2018 at 7:16

1 Answer 1

2

array_filter() will work. Try -

array_filter($array, function ($a) {
    return count($a[0]) == 3; // return array with 3 elements only
});

Working code

Sign up to request clarification or add additional context in comments.

1 Comment

thanks dear but i got an error like too many nested blocks in function declaration.I am using MVC

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.