3v4l.org

run code in 300+ PHP versions simultaneously
<?php $appointments = array( array( 'start_date' => '2018-04-02 12:00:00', 'end_date' => '2018-04-02 12:55:00' ), array( 'start_date' => '2018-04-02 13:00:00', 'end_date' => '2018-04-02 13:55:00' ) ); $begin = new DateTime('2018-04-02 09:00:00'); $end = new DateTime('2018-04-02 18:30:00'); $interval = new DateInterval('PT5M'); $daterange = new DatePeriod($begin, $interval ,$end); $availableDates = []; foreach($daterange as $date) { $availableDates[] = $date; } foreach($appointments as $appointment) { $startsAt = new DateTime($appointment['start_date']); $endsAt = new DateTime($appointment['end_date']); foreach ($availableDates as $key => $date) { if ($startsAt <= $date && $endsAt >= $date) { unset($availableDates[$key]); } } } foreach($availableDates as $date){ echo $date->format("Y-m-d H:i:s") . "\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
2018-04-02 09:00:00 2018-04-02 09:05:00 2018-04-02 09:10:00 2018-04-02 09:15:00 2018-04-02 09:20:00 2018-04-02 09:25:00 2018-04-02 09:30:00 2018-04-02 09:35:00 2018-04-02 09:40:00 2018-04-02 09:45:00 2018-04-02 09:50:00 2018-04-02 09:55:00 2018-04-02 10:00:00 2018-04-02 10:05:00 2018-04-02 10:10:00 2018-04-02 10:15:00 2018-04-02 10:20:00 2018-04-02 10:25:00 2018-04-02 10:30:00 2018-04-02 10:35:00 2018-04-02 10:40:00 2018-04-02 10:45:00 2018-04-02 10:50:00 2018-04-02 10:55:00 2018-04-02 11:00:00 2018-04-02 11:05:00 2018-04-02 11:10:00 2018-04-02 11:15:00 2018-04-02 11:20:00 2018-04-02 11:25:00 2018-04-02 11:30:00 2018-04-02 11:35:00 2018-04-02 11:40:00 2018-04-02 11:45:00 2018-04-02 11:50:00 2018-04-02 11:55:00 2018-04-02 14:00:00 2018-04-02 14:05:00 2018-04-02 14:10:00 2018-04-02 14:15:00 2018-04-02 14:20:00 2018-04-02 14:25:00 2018-04-02 14:30:00 2018-04-02 14:35:00 2018-04-02 14:40:00 2018-04-02 14:45:00 2018-04-02 14:50:00 2018-04-02 14:55:00 2018-04-02 15:00:00 2018-04-02 15:05:00 2018-04-02 15:10:00 2018-04-02 15:15:00 2018-04-02 15:20:00 2018-04-02 15:25:00 2018-04-02 15:30:00 2018-04-02 15:35:00 2018-04-02 15:40:00 2018-04-02 15:45:00 2018-04-02 15:50:00 2018-04-02 15:55:00 2018-04-02 16:00:00 2018-04-02 16:05:00 2018-04-02 16:10:00 2018-04-02 16:15:00 2018-04-02 16:20:00 2018-04-02 16:25:00 2018-04-02 16:30:00 2018-04-02 16:35:00 2018-04-02 16:40:00 2018-04-02 16:45:00 2018-04-02 16:50:00 2018-04-02 16:55:00 2018-04-02 17:00:00 2018-04-02 17:05:00 2018-04-02 17:10:00 2018-04-02 17:15:00 2018-04-02 17:20:00 2018-04-02 17:25:00 2018-04-02 17:30:00 2018-04-02 17:35:00 2018-04-02 17:40:00 2018-04-02 17:45:00 2018-04-02 17:50:00 2018-04-02 17:55:00 2018-04-02 18:00:00 2018-04-02 18:05:00 2018-04-02 18:10:00 2018-04-02 18:15:00 2018-04-02 18:20:00 2018-04-02 18:25:00

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:
30.61 ms | 411 KiB | 5 Q