PHP » GoLang |
login |
register |
about
|
|
array_filter(PHP 4 >= 4.0.6, PHP 5, PHP 7) array_filter — Filters elements of an array using a callback function Description
Iterates over each value in the Parameters
Return ValuesReturns the filtered array. Changelog
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
)
Example #3 array_filter() with
<?phpThe 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
|
more
Most requested
more
Last requests
|