detecting difference between 0 and null
Posted: Sun Feb 19, 2006 1:51 pm
Hi there, I wrote this code for a drop down menu to select a minute. When it creates the drop down menu, 0 is selected even though the $minute variable is null. I tried changing the comparison operator to === but that didn't work either. I know this is probably simple but I forgot how to do it.
Code: Select all
if (($minute == '') and ($minute == null)) { echo '<option selected value=""></option>' . "\n"; }
for ($i = 0; $i <= 60; $i++) {
if ($minute == $i) { echo ' <option selected value="' . $i . '">' . $i . '</option>' . "\n";
} else {
echo '<option value="' . $i . '">' . $i . '</option>' . "\n";
}
}