|
array_filterFilters elements of an array using a callback function Description
array array_filter
( array
$array
[, callable $callback
] )
Iterates over each value in the Parameters
Return ValuesReturns the filtered array. Examples
Example #1 array_filter example
<?phpThe above example will output:
Odd :
Array
(
[a] => 1
[c] => 3
[e] => 5
)
Even:
Array
(
[0] => 6
[2] => 8
[4] => 10
[6] => 12
)
Example #2 array_filter without
<?phpThe above example will output:
Array
(
[0] => foo
[2] => -1
)
NotesCaution
If the array is changed from the callback function (e.g. element added, deleted or unset) the behavior of this function is undefined. See Also
|