| Previous | Home | Next |
array_filter()
The array_filter() function filters the values of an array using a callback function. If the callback function returns true, the current value from input is returned into the result array. Array keys are preserved.
Syntax:array_filter(array,callbackfunction);
Example:
<?php
function test_even($var)
{
return($var & 2);
}
$array1=array("a","b",2,4,6);
print_r(array_filter($array1,"test_even"));
?>
Output:
| Previous | Home | Next |