Im trying to output a dropdown select menu from an array, and it all works fine, but the default option isnt working. Heres what ive got:
<?php
$usertz = $user->$main["timezone"];
foreach($timezonearray as $tz => $off)
{
echo "<option value='$tz'";
if($tz == $usertz)
{
echo 'selected="selected"';
}
echo ">$tz";
if(array_key_exists($tz, $timezonelabelarray))
{
echo " / ".$timezonelabelarray[$tz];
}
echo "</option>";
}
?>
$timezonearray, $timezonelabelarray, and $user are global vars on the server. $timezonearray is a list of timezones from GMT-11 to GMT+13. $timezonelabelarray is a name given to some of them (for example, GMT-5 is also EST). The value of $user->$main["timezone"] is the timezone that the user has selected that all their times be displayed in. This dropdown is supposed to display all the timezones, and default to the timezone that the user has selected to display. Everything works except for the default select. Any ideas?