3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Boilerplate to setup variables */ $start = new \DateTime('2013-01-01'); $end = new \DateTime('2013-12-31'); $interval = new \DateInterval('P1D'); $period = new \DatePeriod($start, $interval, $end->add($interval)); foreach($period as $date){ $dateArray[] = $date->format('Y-m-d'); } /** * End of boilerplate */ /** * Answer code */ $countArray = ['Jan' => 0, 'Feb' => 0, 'Mar' => 0, 'Apr' => 0, 'May' => 0, 'Jun' => 0, 'Jul' => 0, 'Aug' => 0, 'Sep' => 0, 'Oct' => 0, 'Nov' => 0, 'Dec' => 0]; foreach($dateArray as $dateString){ $date = new \DateTime($dateString); $countArray[$date->format('M')]++; } var_dump($countArray);
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.32, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
array(12) { ["Jan"]=> int(31) ["Feb"]=> int(28) ["Mar"]=> int(31) ["Apr"]=> int(30) ["May"]=> int(31) ["Jun"]=> int(30) ["Jul"]=> int(31) ["Aug"]=> int(31) ["Sep"]=> int(30) ["Oct"]=> int(31) ["Nov"]=> int(30) ["Dec"]=> int(31) }
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/iaAq1 on line 20
Process exited with code 255.

preferences:
162.27 ms | 409 KiB | 5 Q