我有一个while
循环,它给出从00:00到23:30的输出。但我想要与for
循环的结果相同。从while更改循环到
代码:
<select>
<?php
$start_time = "00:00:00";
$end_time = "23:00:00";
while(strtotime($start_time) <= strtotime($end_time)){?>
<option value="<?php date("H:i:s", strtotime($start_time))?>"> <?php echo date("H:i A", strtotime($start_time))?></option>
<?php $start_time = date("H:i:s", strtotime("$start_time + 15 minutes"));
}
?></select>
不会你需要'while'或'for'工作数组...? – webeno 2014-09-19 06:37:46
为什么你想改变它,如果它的工作? while循环可能是更好的解决方案。 – TiMESPLiNTER 2014-09-19 06:38:11
为什么你想去for循环?你将不会从中得到好处。 – 2014-09-19 06:40:08