3v4l.org

run code in 300+ PHP versions simultaneously
<?php function countDaysForChoosenYears(int $year):int { $att = []; for ($i = 1; $i <= 12; $i++) { $att[] = cal_days_in_month(CAL_GREGORIAN, $i, $year); } $att = array_sum($att); return $att; } $YearMonthDayStructure = []; $Date = new DateTime('2016-01-01'); for ($i = 1; $i <= countDaysForChoosenYears(2016); $i++) { $monthName = $Date->format('F'); $yearNumber = $Date->format('Y'); $YearMonthDayStructure[$yearNumber][$monthName][$Date->format('d')] = $Date->format('Y-m-d'); $Date->add(new DateInterval('P1D')); } print_r($YearMonthDayStructure);

preferences:
23.52 ms | 405 KiB | 5 Q