- var_export: documentation ( source)
<?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);
This script was stopped while abusing our resources