3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isWeekend($date) { return $date->format('N') >= 6; } function getDayOffInDaysOffByDate($daysOff, \DateTime $date) { $dayOffInDate = null; foreach ($daysOff as $dayOff) { if ($dayOff->getDate()->format('Y-m-d') == $date->format('Y-m-d')) { $dayOffInDate = $dayOff; } } return $dayOffInDate; } $daysOff = array(new \DateTime('2017-07-03'), new \DateTime('2017-07-04')); $periodStartDate = new \DateTime('today'); $periodStartDate = $periodStartDate->modify('-5 days'); $periodEndDate = new \DateTime('today'); $periodEndDate->modify('+1 day'); $period = new \DatePeriod($periodStartDate, \DateInterval::createFromDateString('1 day'), $periodEndDate); foreach ($period as $date) { echo $date->format('Y-m-d'); echo('\n'); if (getDayOffInDaysOffByDate($daysOff, $date) || isWeekend($date)) { echo('minus'); } }
Output for git.master, git.master_jit, rfc.property-hooks
2017-06-30\n Fatal error: Uncaught Error: Call to undefined method DateTime::getDate() in /in/dGYeI:12 Stack trace: #0 /in/dGYeI(30): getDayOffInDaysOffByDate(Array, Object(DateTime)) #1 {main} thrown in /in/dGYeI on line 12
Process exited with code 255.

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:
49.07 ms | 401 KiB | 8 Q