3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getPlayDays($startWeek, $numWeeks) { $numWeeks --; $result = []; $currYear = (int)(new \DateTime())->format('Y'); $oneDay = new \DateInterval('P1D'); // Start on the first Thursday of the given week. $startDate = (new \DateTime())->setISODate($currYear, $startWeek, 4); $endDate = clone $startDate; $endDate->add(new \DateInterval("P{$numWeeks}W")); // End on the Sunday of the last week. $endDate->setISODate((int)$endDate->format('o'), (int)$endDate->format('W'), 7); $period = new \DatePeriod($startDate, $oneDay, $endDate->add($oneDay)); foreach($period as $day){ if(4 === (int)$day->format('N') || 7 === (int)$day->format('N') ){ $result[] = $day; } } return $result; } foreach(getPlayDays(1, 3) as $playDay){ var_dump($playDay->format('D m-d-Y')); }
Output for git.master, git.master_jit, rfc.property-hooks
string(14) "Thu 01-06-2022" string(14) "Sun 01-09-2022" string(14) "Thu 01-13-2022" string(14) "Sun 01-16-2022" string(14) "Thu 01-20-2022" string(14) "Sun 01-23-2022"

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