array_filter

It filters elements of an array using a callback function

Example

<?php
function checkOdd($arg){
return($arg & 1);
}
echo “<pre>”;
$array1 = array(1,2, 3, 4, 5, 17, 12);
print_r(array_filter($array1, “checkOdd”));
?>

Output

Array
(
[0] => 1
[2] => 3
[4] => 5
[5] => 17
)

Share