3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isMonday($date) { return $date->format('N') === '1'; } function isSunday($date) { return $date->format('N') === '7'; } function getMondays($start, $end) { $mondays = []; $datePeriod = new DatePeriod($start, new DateInterval('P1D'), $end); foreach ($datePeriod as $date) { if (isMonday($date)) $mondays[] = $date; } if (!isSunday($end)) array_pop($mondays); return $mondays; } $startDate = new DateTime('2021-06-20'); $endDate = new DateTime('2021-07-07'); var_dump(getMondays($startDate, $endDate));
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { [0]=> object(DateTime)#10 (3) { ["date"]=> string(26) "2021-06-21 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [1]=> object(DateTime)#9 (3) { ["date"]=> string(26) "2021-06-28 00:00: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:
166.09 ms | 406 KiB | 5 Q