• 91 9823089875

Filter array based on key value

By using function array_filter, you can create a subset of the array

$NUM = 5;
$items = array(1, 4, 5, 8, 0, 6);
$filteredItems = array_filter($items, function($elem) use($NUM){
return $elem < $NUM;
});
});


Share