array_filter
PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8
array_filter - Filters elements of an array using a callback function
Example #1 array_filter example
Result: Odd :
Array
(
[a] => 1
[c] => 3
[e] => 5
)
Even:
Array
(
[0] => 6
[2] => 8
[4] => 10
[6] => 12
)
Example #2 array_filter without
<span class='function-parameter'>callback</span>
Result: Array
(
[0] => foo
[2] => -1
)
Example #3 array_filter with
<span class='function-parameter'>mode</span>
Result: array(1) {
["b"]=>
int(2)
}
array(2) {
["b"]=>
int(2)
["d"]=>
int(4)
}