- range: documentation ( source)
<?php $options = array();
foreach (range(0,23) as $fullhour)
{
$parthour = $fullhour > 12 ? $fullhour - 12 : $fullhour;
$sufix = $fullhour > 11 ? " pm" : " am";
$options["$fullhour:00"] = $parthour.":00".$sufix;
$options["$fullhour:30"] = $parthour.":30".$sufix;
}
?>