I have this multidimensional array $currencies
:
$currencies = array (
0 => (object) array( 'name' => 'algo', 'fullName' => 'Algorand'),
1 => (object) array( 'name' => 'ardr', 'fullName' => 'Ardor'),
2 => (object) array( 'name' => 'eth', 'fullName' => 'Eth')
);
And I want to keep only the objects with a name
that is in this array:
$filter = ["eth", "algo"];
I did this, but it doesn't work.
$currenciesFiltered = array_filter(
$currencies,
function ($value) use ($filter) {
return in_array($value['name'], $filter);
}
);
Where is my mistake?