3v4l.org

run code in 300+ PHP versions simultaneously
<?php $result = []; $dt = new DateTime('first day of this month'); $month = $dt->format('n'); $dt->modify('-1 day'); while ($dt->modify('next weekday') && $dt->format('n') == $month) { $result[$dt->format('Y')][$dt->format('n')][] = $dt->format('d'); } var_export($result); echo "\n---\n"; $result = []; foreach ([2023, 2024] as $year) { $dt = new DateTime("$year-01-01 -1 day"); while ($dt->modify('next weekday') && $dt->format('Y') == $year) { $result[$year][$dt->format('n')][] = $dt->format('d'); } } var_export($result);

Abusive script

This script was stopped while abusing our resources


preferences:
26.11 ms | 404 KiB | 5 Q