Im iterating a time array through a foreach loop. This loop is in a form. If the user submits the form and the there is a problem, it stops the processing. I have my form setup so that the $POST variables are passed back to the form and populate the form boxes. While everything works fine, and all the $POST variables are passing back to the form including the time variable, it will not populate the time select box. Is there an issue with using a foreach loop in how I have it setup?
Heres my code
$eTime = array('12:00pm','12:30pm','1:00pm','1:30pm','2:00pm','2:30pm','3:00pm',
'3:30pm','4:00pm','4:30pm','5:00pm','5:30pm','','7:00pm','7:30pm',
'8:00pm','8:30m','9:00pm','9:30pm','10:00pm','10:30pm','11:00pm','11:30pm','12:00am',
'12:30am','1:00am','2:00am','3:00am','4:00am','5:00am','6:00am','7:00am');
foreach ($eTime as $value) {
if ($time2 == $value) {
$selected = "selected";
} else {
$selected = "";
}
echo "<option value=\"$value\" $selected;>$value</option>";
}
Note: There is a blank variable in the array, as Ive purposely put it there for a space in the drop down.