date intervals of 15 minutes between 9-5
heres my code, all i want to do is echo the values so they come up in a SELECT input in the following format:
9:00 9:15 9:30 9:45 10:00 10:15 ETC.
heres my code which just crashes the page:
<select>
<option>Select Time</option>
<?php
for ($i = 9; $i <= 12; $i++)
{
for ($j = 0; $j <= 45; $j+15)
{
开发者_如何学Pythonecho '<option>'.$i.':'.str_pad($j, 2, '0', STR_PAD_LEFT).'</option>';
}
}
?>
</select>
Wrong $j increment. You should use this:
$j+=15
You're not properly incrementing the $j
loop:
Do this:
<?php
for ($i=9;$i<=12;$i++){
for ($j=0;$j<=45;$j=$j+15)
{
echo '<option>'.$i.':'.str_pad($j, 2, '0', STR_PAD_LEFT).'</option>';
}
}
?>
精彩评论