PHP Programing language

array_filter() Functions in PHP
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:

Array ( [2] => 2 [4] => 6 )

Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: