3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getSundays($y, $m) { return new DatePeriod( new DateTime("first Sunday of $y-$m"), DateInterval::createFromDateString('next sunday'), new DateTime("last day of $y-$m") ); } $days=""; foreach (getSundays(2016, 04) as $Sunday) { $days[] = $Sunday->format("d"); } var_dump($days);
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.27, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
Fatal error: Uncaught Error: [] operator not supported for strings in /in/DVYM5:14 Stack trace: #0 {main} thrown in /in/DVYM5 on line 14
Process exited with code 255.
Output for 5.5.0 - 5.5.37, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20
array(4) { [0]=> string(2) "03" [1]=> string(2) "10" [2]=> string(2) "17" [3]=> string(2) "24" }

preferences:
74.56 ms | 407 KiB | 5 Q