3v4l.org

run code in 300+ PHP versions simultaneously
<?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); ?>

preferences:
38.41 ms | 402 KiB | 5 Q