filter array in php with passing extra params

75

$a = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$p = 5;
 
$r = array_filter($a, function($i) use ($p) { return $i < $p; });
print_r($r);

Comments

Submit
0 Comments