I want to use a php array to select an HTML list. In this case, it will be a list of countries, but in addition to the name of the country, which is listed in the drop-down list, I need as the value of a short country code for each country.
The php array that I am currently using looks like this:
$wcr=array( 'Angola', 'Antigua & Barbuda', 'Armenia', 'Austria', 'Azerbaijan', ..... );
PHP page using this array:
<select name="country"><option selected value=""> --------- <? $p=1;asort($wcr);reset($wcr); while (list ($p, $val) = each ($wcr)) { echo '<option value="'.$p.'">'.$val; } ?> </select>
The value should be a short country code (something like "ES", "US", "AN", ...) instead of the numbers that I now have as the values ββin this form. In these short country codes, I will write in the same PHP array somewhere, if possible.
How can i do this?
source share