PHP Code:
function genOptions($passedarray,$default="") {
while ($thiskey = key($passedarray)) {
$returnval .= "<option value=\"$thiskey\"";
if ($thiskey == $default) { $returnval .= " selected"; }
$returnval .= ">" . $passedarray[$thiskey] . "</option>";
next($passedarray);
}
return $returnval;
}
$countries = array("AF" => "Afghanistan","AL" => "Albania","DZ"=>"Algeria");
$countries = asort($countries);
$countryoptions genOptions($countries,$country);
Marc.
Leave a comment: