3v4l.org

run code in 300+ PHP versions simultaneously
<?php function rangeWeek(string $start,string $end): array{ $dtStart = date_create($start); $dtEnd = date_create($end); $weeks = []; while($dtStart <= $dtEnd){ $weeks[] = [ 'start' => $dtStart->format('Y-m-d'), 'end' => min($dtEnd,$dtStart->modify('Sunday this week'))->format('Y-m-d'), 'week' => $dtStart->format('W') ]; $dtStart->modify('next Monday'); } return $weeks; } $startDate = '2022-08-08'; //Monday $endDate = '2022-08-23'; //Tuesday $weeks = rangeWeek($startDate, $endDate); var_dump($weeks);
Output for git.master, git.master_jit, rfc.property-hooks
array(3) { [0]=> array(3) { ["start"]=> string(10) "2022-08-08" ["end"]=> string(10) "2022-08-14" ["week"]=> string(2) "32" } [1]=> array(3) { ["start"]=> string(10) "2022-08-15" ["end"]=> string(10) "2022-08-21" ["week"]=> string(2) "33" } [2]=> array(3) { ["start"]=> string(10) "2022-08-22" ["end"]=> string(10) "2022-08-23" ["week"]=> string(2) "34" } }

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:
117.02 ms | 406 KiB | 5 Q