I have a two dimensional array. I'm trying to get the key/index name of a given value. How do I do this? I went through the PHP manual and they suggest to do an iteration, but I do not want to iterate. Is there a way to do without iteration?
I would like to do something similar to
$country = 'Algeria';
echo $iso_countries[$country]; //obviously this will throw an error since the index does not exist. It's just an example.
array
$iso_countries = array
(
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
);
array_flip()will do.