|
array_filterFilters elements of an array using a callback function Description
array array_filter
( array
$array
[, callable $callback
[, int $flag = 0
]] )
Iterates over each value in the Parameters
Return ValuesReturns the filtered array. Changelog
Examples
Example #1 array_filter example
<?php The 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
<?php The above example will output: Array ( [0] => foo [2] => -1 ) Example #3 array_filter with
<?php The above example will output: array(1) { ["b"]=> int(2) } array(2) { ["b"]=> int(2) ["d"]=> int(4) } 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
|