array_filter function in php

by banumathi 2011-08-30 18:13:31

Suppose we have an array $a like this

Array ( [0] => abc [1] => dcf [2] => [3] => [4] => [5] => )

Here we need to check whether the array element is empty and pop that element.

We can easily achieve this by array_filter()

print_r(array_filter($a));

The output will be

Array ( [0] => abc [1] => dcf )

We can also write call back functions that can be passed as a parameter to array_filter() function.

Tagged in:

976
like
0
dislike
0
mail
flag

You must LOGIN to add comments