I've got an array of country ISO codes
$countries = array("AU","CA","CO","DE","DK","ES","GB","GR","IL","IN","IT","NO","PA","US","ZA");
Now I'm building a list via a loop:
foreach ($countries as $key => $value) {
echo $value.'<br>';
}
The results I get look fine
AU
CA
CO
DE
DK
ES
GB
etc.
Now I'd like to use another array to replace ISO codes with full country names.
$iso2name = array("AU" => "AUSTRALIA", "CA" => "CANADA", ... "DK" => "DENMARK");
by doing
foreach ($countriesas $key => $value) {
echo $iso2name[$value].'<br>';
}
However, now my output looks out of order
Australia
Canada
Colombia
Germany
Denmark
Spain
United Kingdom
Greece
Israel
India
Italy
Norway
Panama
United States
South Africa
Is there any way the final list could be sorted alphabetically? If yes, how?
😕