3v4l.org

run code in 300+ PHP versions simultaneously
<?php function createRange($start, $end, $format = 'Y-m-d') { $start = new DateTime($start); $end = new DateTime($end); $invert = $start > $end; $dates = array(); $dates[] = $start->format($format); while ($start != $end) { $start->modify(($invert ? '-' : '+') . '1 day'); $dates[] = $start->format($format); } return $dates; } print_r(createRange('2010-10-01', '2010-10-05')); print_r(createRange('2010-10-05', '2010-10-01', 'j M Y'));

preferences:
59.18 ms | 404 KiB | 5 Q