The code below filters a multidimensional array by the ID of 152.
$new = array_filter($test, function ($output) {
return ($output['_id'] == 152);
});
Is there a way to make it work with multiple IDs? For example 152, 154, 155
The code below filters a multidimensional array by the ID of 152.
$new = array_filter($test, function ($output) {
return ($output['_id'] == 152);
});
Is there a way to make it work with multiple IDs? For example 152, 154, 155
Yes , you can try this :
$new = array_filter($test, function ($output) {
return (in_array($output['_id'] , [152,154,155]));
});