I want to search an array by value, not by key. It's an array of country code => country name, as below.
$countries = array (
'AF' => 'Afghanistan',
'AX' => 'Åland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa');
Of course, PHP's array_search() is a perfect candidate, however I don't want to return the key of the found element, but the value. The only way I can think of doing this is to use the following (from a function):
return $countries[array_search($string, $countries)];
Is there a better/faster way to do this?