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('Y'), $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.3.0 - 5.4.35, 5.6.28, 7.0.14 - 7.1.0
array(7) { [0]=> string(10) "09/06/2014" [1]=> string(10) "10/06/2014" [2]=> string(10) "11/06/2014" [3]=> string(10) "12/06/2014" [4]=> string(10) "13/06/2014" [5]=> string(10) "14/06/2014" [6]=> string(10) "15/06/2014" }
Output for 5.5.24 - 5.6.21, 7.0.0 - 7.0.6
array(7) { [0]=> string(10) "13/06/2016" [1]=> string(10) "14/06/2016" [2]=> string(10) "15/06/2016" [3]=> string(10) "16/06/2016" [4]=> string(10) "17/06/2016" [5]=> string(10) "18/06/2016" [6]=> string(10) "19/06/2016" }
Output for 5.4.36 - 5.4.45
array(7) { [0]=> string(10) "08/06/2015" [1]=> string(10) "09/06/2015" [2]=> string(10) "10/06/2015" [3]=> string(10) "11/06/2015" [4]=> string(10) "12/06/2015" [5]=> string(10) "13/06/2015" [6]=> string(10) "14/06/2015" }
Output for 5.2.0 - 5.2.17
Fatal error: Class 'DateInterval' not found in /in/uPfCG on line 7
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/uPfCG 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/uPfCG 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/uPfCG on line 5