| 
        
            array_filterFilters elements of an array using a callback function Description
   array array_filter(array  
  $array, callablenull $callback = null, int $mode = 0)
   Iterates over each value in the  
   Array keys are preserved, and may result in gaps if the  Parameters
 
 Return ValuesReturns the filtered array. Changelog
 Examples
 Example #1 array_filter example 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
     The above example will output: 
Array
(
    [0] => foo
    [2] => -1
)
Example #3 array_filter with
     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 or unset) the behavior of this function is undefined. See Also
 
  |