3v4l.org

run code in 300+ PHP versions simultaneously
<?php function weeks_in_month($month, $year) { $dates = []; $week = 1; $date = new DateTime("$year-$month-01"); $days = (int)$date->format('t'); // total number of days in the month $oneDay = new DateInterval('P1D'); for ($day = 1; $day <= $days; $day++) { $dates["Week $week"] []= $date->format('d/m/Y'); $dayOfWeek = $date->format('l'); if ($dayOfWeek === 'Saturday') { $week++; } $date->add($oneDay); } return $dates; } print_r(weeks_in_month(1, 2018));
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [Week 1] => Array ( [0] => 01/01/2018 [1] => 02/01/2018 [2] => 03/01/2018 [3] => 04/01/2018 [4] => 05/01/2018 [5] => 06/01/2018 ) [Week 2] => Array ( [0] => 07/01/2018 [1] => 08/01/2018 [2] => 09/01/2018 [3] => 10/01/2018 [4] => 11/01/2018 [5] => 12/01/2018 [6] => 13/01/2018 ) [Week 3] => Array ( [0] => 14/01/2018 [1] => 15/01/2018 [2] => 16/01/2018 [3] => 17/01/2018 [4] => 18/01/2018 [5] => 19/01/2018 [6] => 20/01/2018 ) [Week 4] => Array ( [0] => 21/01/2018 [1] => 22/01/2018 [2] => 23/01/2018 [3] => 24/01/2018 [4] => 25/01/2018 [5] => 26/01/2018 [6] => 27/01/2018 ) [Week 5] => Array ( [0] => 28/01/2018 [1] => 29/01/2018 [2] => 30/01/2018 [3] => 31/01/2018 ) )

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:
34.72 ms | 409 KiB | 5 Q