- print_r: documentation ( source)
- range: documentation ( source)
<?php $options = array(); $min30=array('00','30');
foreach (range(0,23) as $fullhour) {
$parthour = $fullhour > 12 ? $fullhour - 12 : $fullhour;
foreach($min30 as $int){
if($fullhour > 11){
$options[$fullhour.".".$int]=$parthour.":".$int." PM";
}else{
if($fullhour == 0){$parthour='12';}
$options[$fullhour.".".$int]=$parthour.":".$int." AM" ;
}
}
}
print_r($options);
?>