PHP array to HTML select

htmlphp

I have a list of countries in this format in an external file:

<? $countries=array();
$countries['AF']='Afghanistan';
$countries['AL']='Albania';
$countries['DZ']='Algeria';
$countries['AS']='American Samoa';
$countries['AD']='Andorra';
$countries['AO']='Angola'; ?>

How can I make them list as options in a HTML select, with the abreviation (ex: 'AF') being the value and the full name of the country, the displayed text?

Ex: <option value="AF">Afghanistan</option>

Best Solution

foreach($countries as $cc => $name) {
    echo '<option value="' . $cc . '">' . $name . '</option>';
}

If the external file only contains the country list (btw, use <?php instead of <?!!), simply include it.