Say I have an array such as:
$arr[] = array("id" => 11, "name" => "First");
$arr[] = array("id" => 52, "name" => "Second");
$arr[] = array("id" => 6, "name" => "Third");
$arr[] = array("id" => 43, "name" => "Fourth");
I would like to get the name correspondent to a certain ID so that I can do:
$name = findNameFromID(43);
and get, for instance, "Fourth".
I thought of using array_filter
but I am a bit stuck on how to correctly pass a variable. I have seen questions such as this one but I don't seem to be able to extend the solution to a multidimensional array.
Any help?