PHP Tutorial : Country list array

In my point of view, a very usefull and common thing we need when we build for example a membership site it’s country list array. I will do it within next function then will show how to use it :

Click here to get the function

And here’s how to use it for example to generate a select (drop down) with options to list countries:

<?php
$countryList = countryArray();

print "<select name=\"countryList\">";

foreach($countryList as $simbol => $country) {

print "<option value=\"$simbol\">$country</option>\n";
}

print "</select>";
?>

Simply usefull!

This entry was posted in Usefull PHP and tagged , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>