3v4l.org

run code in 300+ PHP versions simultaneously
<?php $start = new \DateTime('2019-05-08 07:00:00'); $end = new \DateTime('2019-05-08 07:30:00'); function getSlots(\DateTime $start, \DateTime $end): array { $slots = []; while ($start < $end) { $old = clone($start); $start->modify('+2 hours'); if ($start > $end) { echo 1; $slots[] = [ 'from' => $old, 'to' => $end ]; return $slots; } else { $slots[] = [ 'from' => $old, 'to' => clone($start) ]; } } return $slots; } var_dump(getSlots($start, $end));
Output for git.master, git.master_jit, rfc.property-hooks
1array(1) { [0]=> array(2) { ["from"]=> object(DateTime)#3 (3) { ["date"]=> string(26) "2019-05-08 07:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["to"]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2019-05-08 07:30:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } } }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
103.04 ms | 402 KiB | 8 Q