3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function daysInWeek($weekNum) { $result = array(); $datetime = new DateTime(); $datetime->setISODate((int)$datetime->format('O'), $weekNum, 1); $interval = new DateInterval('P1D'); $week = new DatePeriod($datetime, $interval, 6); foreach($week as $day){ $result[] = $day->format('d/m/Y'); } return $result; } var_dump(daysInWeek(24));
Output for 5.4.24 - 5.4.25, 5.4.34 - 5.4.38, 5.5.31 - 5.5.33, 5.6.17 - 5.6.19, 5.6.28, hhvm-3.12.0, 7.0.0 - 7.0.4, 7.0.7 - 7.1.0
array(7) { [0]=> string(10) "14/06/0100" [1]=> string(10) "15/06/0100" [2]=> string(10) "16/06/0100" [3]=> string(10) "17/06/0100" [4]=> string(10) "18/06/0100" [5]=> string(10) "19/06/0100" [6]=> string(10) "20/06/0100" }
Output for 5.4.26 - 5.4.32, 5.4.39 - 5.5.30, 5.5.34 - 5.6.16, 5.6.20 - 5.6.21, hhvm-3.10.0, 7.0.5 - 7.0.6
array(7) { [0]=> string(10) "09/06/0200" [1]=> string(10) "10/06/0200" [2]=> string(10) "11/06/0200" [3]=> string(10) "12/06/0200" [4]=> string(10) "13/06/0200" [5]=> string(10) "14/06/0200" [6]=> string(10) "15/06/0200" }
Output for 5.3.0 - 5.3.28, 5.4.0 - 5.4.23
array(7) { [0]=> string(10) "13/06/0100" [1]=> string(10) "14/06/0100" [2]=> string(10) "15/06/0100" [3]=> string(10) "16/06/0100" [4]=> string(10) "17/06/0100" [5]=> string(10) "18/06/0100" [6]=> string(10) "19/06/0100" }
Output for 5.3.29
array(7) { [0]=> string(10) "08/06/0200" [1]=> string(10) "09/06/0200" [2]=> string(10) "10/06/0200" [3]=> string(10) "11/06/0200" [4]=> string(10) "12/06/0200" [5]=> string(10) "13/06/0200" [6]=> string(10) "14/06/0200" }
Output for 5.2.0 - 5.2.17
Fatal error: Class 'DateInterval' not found in /in/2nVL6 on line 7
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/2nVL6 on line 5
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetime in /in/2nVL6 on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetime in /in/2nVL6 on line 5