if ($country == "us"){$display = "United States";} elseif ($country == "au"){$display = "Australia";} elseif ($country == "fr"){$display = "France";} elseif ($country == "de"){$display = "Germany";} elseif ($country == "it"){$display = "Italy";} elseif ($country == "es"){$display = "Spain";} elseif ($country == "uk"){$display = "United Kingdom";} ..... and so on echo "Country: $country";
There are around 200 countries and I guess it's not a good idea to list them all in this way. Any idea how I can shorten this code without using MySQL database? Or you think it's ok like this?
use an array. store the country abbreviation as the key, and the full name as the value. then just do: $display= $countryarray[$country]
maxpup979 wrote:use an array. store the country abbreviation as the key, and the full name as the value. then just do: $display= $countryarray[$country]
It would be very helpful if you can give me a short example. Sorry, I'm a newbie.
$countries = array( "us" => "United States", "au" => "Australia", "fr" => "France", "de" => "Germany", "it" => "Italy", "es" => "Spain", "uk" => "United Kingdom" ); echo $countries[$country];
Thnaks a lot 🙂