Utilize array_filter() to apply a callback to each element; handy for conditional checks.
Source Code
$numbers = [1, 2, 3, 4, 5];
$even = array_filter($numbers, function($number) {
return $number % 2 === 0;
});
print_r($even); // Outputs: Array ( [1] => 2 [3] => 4 )