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);
Output for 7.1.20 - 7.1.33, 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.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.14, 8.4.1
Fatal error: Uncaught Error: Call to undefined function cal_days_in_month() in /in/p2518:6 Stack trace: #0 /in/p2518(17): countDaysForChoosenYears(2016) #1 {main} thrown in /in/p2518 on line 6
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.10
Array ( [2016] => Array ( [January] => Array ( [01] => 2016-01-01 [02] => 2016-01-02 [03] => 2016-01-03 [04] => 2016-01-04 [05] => 2016-01-05 [06] => 2016-01-06 [07] => 2016-01-07 [08] => 2016-01-08 [09] => 2016-01-09 [10] => 2016-01-10 [11] => 2016-01-11 [12] => 2016-01-12 [13] => 2016-01-13 [14] => 2016-01-14 [15] => 2016-01-15 [16] => 2016-01-16 [17] => 2016-01-17 [18] => 2016-01-18 [19] => 2016-01-19 [20] => 2016-01-20 [21] => 2016-01-21 [22] => 2016-01-22 [23] => 2016-01-23 [24] => 2016-01-24 [25] => 2016-01-25 [26] => 2016-01-26 [27] => 2016-01-27 [28] => 2016-01-28 [29] => 2016-01-29 [30] => 2016-01-30 [31] => 2016-01-31 ) [February] => Array ( [01] => 2016-02-01 [02] => 2016-02-02 [03] => 2016-02-03 [04] => 2016-02-04 [05] => 2016-02-05 [06] => 2016-02-06 [07] => 2016-02-07 [08] => 2016-02-08 [09] => 2016-02-09 [10] => 2016-02-10 [11] => 2016-02-11 [12] => 2016-02-12 [13] => 2016-02-13 [14] => 2016-02-14 [15] => 2016-02-15 [16] => 2016-02-16 [17] => 2016-02-17 [18] => 2016-02-18 [19] => 2016-02-19 [20] => 2016-02-20 [21] => 2016-02-21 [22] => 2016-02-22 [23] => 2016-02-23 [24] => 2016-02-24 [25] => 2016-02-25 [26] => 2016-02-26 [27] => 2016-02-27 [28] => 2016-02-28 [29] => 2016-02-29 ) [March] => Array ( [01] => 2016-03-01 [02] => 2016-03-02 [03] => 2016-03-03 [04] => 2016-03-04 [05] => 2016-03-05 [06] => 2016-03-06 [07] => 2016-03-07 [08] => 2016-03-08 [09] => 2016-03-09 [10] => 2016-03-10 [11] => 2016-03-11 [12] => 2016-03-12 [13] => 2016-03-13 [14] => 2016-03-14 [15] => 2016-03-15 [16] => 2016-03-16 [17] => 2016-03-17 [18] => 2016-03-18 [19] => 2016-03-19 [20] => 2016-03-20 [21] => 2016-03-21 [22] => 2016-03-22 [23] => 2016-03-23 [24] => 2016-03-24 [25] => 2016-03-25 [26] => 2016-03-26 [27] => 2016-03-27 [28] => 2016-03-28 [29] => 2016-03-29 [30] => 2016-03-30 [31] => 2016-03-31 ) [April] => Array ( [01] => 2016-04-01 [02] => 2016-04-02 [03] => 2016-04-03 [04] => 2016-04-04 [05] => 2016-04-05 [06] => 2016-04-06 [07] => 2016-04-07 [08] => 2016-04-08 [09] => 2016-04-09 [10] => 2016-04-10 [11] => 2016-04-11 [12] => 2016-04-12 [13] => 2016-04-13 [14] => 2016-04-14 [15] => 2016-04-15 [16] => 2016-04-16 [17] => 2016-04-17 [18] => 2016-04-18 [19] => 2016-04-19 [20] => 2016-04-20 [21] => 2016-04-21 [22] => 2016-04-22 [23] => 2016-04-23 [24] => 2016-04-24 [25] => 2016-04-25 [26] => 2016-04-26 [27] => 2016-04-27 [28] => 2016-04-28 [29] => 2016-04-29 [30] => 2016-04-30 ) [May] => Array ( [01] => 2016-05-01 [02] => 2016-05-02 [03] => 2016-05-03 [04] => 2016-05-04 [05] => 2016-05-05 [06] => 2016-05-06 [07] => 2016-05-07 [08] => 2016-05-08 [09] => 2016-05-09 [10] => 2016-05-10 [11] => 2016-05-11 [12] => 2016-05-12 [13] => 2016-05-13 [14] => 2016-05-14 [15] => 2016-05-15 [16] => 2016-05-16 [17] => 2016-05-17 [18] => 2016-05-18 [19] => 2016-05-19 [20] => 2016-05-20 [21] => 2016-05-21 [22] => 2016-05-22 [23] => 2016-05-23 [24] => 2016-05-24 [25] => 2016-05-25 [26] => 2016-05-26 [27] => 2016-05-27 [28] => 2016-05-28 [29] => 2016-05-29 [30] => 2016-05-30 [31] => 2016-05-31 ) [June] => Array ( [01] => 2016-06-01 [02] => 2016-06-02 [03] => 2016-06-03 [04] => 2016-06-04 [05] => 2016-06-05 [06] => 2016-06-06 [07] => 2016-06-07 [08] => 2016-06-08 [09] => 2016-06-09 [10] => 2016-06-10 [11] => 2016-06-11 [12] => 2016-06-12 [13] => 2016-06-13 [14] => 2016-06-14 [15] => 2016-06-15 [16] => 2016-06-16 [17] => 2016-06-17 [18] => 2016-06-18 [19] => 2016-06-19 [20] => 2016-06-20 [21] => 2016-06-21 [22] => 2016-06-22 [23] => 2016-06-23 [24] => 2016-06-24 [25] => 2016-06-25 [26] => 2016-06-26 [27] => 2016-06-27 [28] => 2016-06-28 [29] => 2016-06-29 [30] => 2016-06-30 ) [July] => Array ( [01] => 2016-07-01 [02] => 2016-07-02 [03] => 2016-07-03 [04] => 2016-07-04 [05] => 2016-07-05 [06] => 2016-07-06 [07] => 2016-07-07 [08] => 2016-07-08 [09] => 2016-07-09 [10] => 2016-07-10 [11] => 2016-07-11 [12] => 2016-07-12 [13] => 2016-07-13 [14] => 2016-07-14 [15] => 2016-07-15 [16] => 2016-07-16 [17] => 2016-07-17 [18] => 2016-07-18 [19] => 2016-07-19 [20] => 2016-07-20 [21] => 2016-07-21 [22] => 2016-07-22 [23] => 2016-07-23 [24] => 2016-07-24 [25] => 2016-07-25 [26] => 2016-07-26 [27] => 2016-07-27 [28] => 2016-07-28 [29] => 2016-07-29 [30] => 2016-07-30 [31] => 2016-07-31 ) [August] => Array ( [01] => 2016-08-01 [02] => 2016-08-02 [03] => 2016-08-03 [04] => 2016-08-04 [05] => 2016-08-05 [06] => 2016-08-06 [07] => 2016-08-07 [08] => 2016-08-08 [09] => 2016-08-09 [10] => 2016-08-10 [11] => 2016-08-11 [12] => 2016-08-12 [13] => 2016-08-13 [14] => 2016-08-14 [15] => 2016-08-15 [16] => 2016-08-16 [17] => 2016-08-17 [18] => 2016-08-18 [19] => 2016-08-19 [20] => 2016-08-20 [21] => 2016-08-21 [22] => 2016-08-22 [23] => 2016-08-23 [24] => 2016-08-24 [25] => 2016-08-25 [26] => 2016-08-26 [27] => 2016-08-27 [28] => 2016-08-28 [29] => 2016-08-29 [30] => 2016-08-30 [31] => 2016-08-31 ) [September] => Array ( [01] => 2016-09-01 [02] => 2016-09-02 [03] => 2016-09-03 [04] => 2016-09-04 [05] => 2016-09-05 [06] => 2016-09-06 [07] => 2016-09-07 [08] => 2016-09-08 [09] => 2016-09-09 [10] => 2016-09-10 [11] => 2016-09-11 [12] => 2016-09-12 [13] => 2016-09-13 [14] => 2016-09-14 [15] => 2016-09-15 [16] => 2016-09-16 [17] => 2016-09-17 [18] => 2016-09-18 [19] => 2016-09-19 [20] => 2016-09-20 [21] => 2016-09-21 [22] => 2016-09-22 [23] => 2016-09-23 [24] => 2016-09-24 [25] => 2016-09-25 [26] => 2016-09-26 [27] => 2016-09-27 [28] => 2016-09-28 [29] => 2016-09-29 [30] => 2016-09-30 ) [October] => Array ( [01] => 2016-10-01 [02] => 2016-10-02 [03] => 2016-10-03 [04] => 2016-10-04 [05] => 2016-10-05 [06] => 2016-10-06 [07] => 2016-10-07 [08] => 2016-10-08 [09] => 2016-10-09 [10] => 2016-10-10 [11] => 2016-10-11 [12] => 2016-10-12 [13] => 2016-10-13 [14] => 2016-10-14 [15] => 2016-10-15 [16] => 2016-10-16 [17] => 2016-10-17 [18] => 2016-10-18 [19] => 2016-10-19 [20] => 2016-10-20 [21] => 2016-10-21 [22] => 2016-10-22 [23] => 2016-10-23 [24] => 2016-10-24 [25] => 2016-10-25 [26] => 2016-10-26 [27] => 2016-10-27 [28] => 2016-10-28 [29] => 2016-10-29 [30] => 2016-10-30 [31] => 2016-10-31 ) [November] => Array ( [01] => 2016-11-01 [02] => 2016-11-02 [03] => 2016-11-03 [04] => 2016-11-04 [05] => 2016-11-05 [06] => 2016-11-06 [07] => 2016-11-07 [08] => 2016-11-08 [09] => 2016-11-09 [10] => 2016-11-10 [11] => 2016-11-11 [12] => 2016-11-12 [13] => 2016-11-13 [14] => 2016-11-14 [15] => 2016-11-15 [16] => 2016-11-16 [17] => 2016-11-17 [18] => 2016-11-18 [19] => 2016-11-19 [20] => 2016-11-20 [21] => 2016-11-21 [22] => 2016-11-22 [23] => 2016-11-23 [24] => 2016-11-24 [25] => 2016-11-25 [26] => 2016-11-26 [27] => 2016-11-27 [28] => 2016-11-28 [29] => 2016-11-29 [30] => 2016-11-30 ) [December] => Array ( [01] => 2016-12-01 [02] => 2016-12-02 [03] => 2016-12-03 [04] => 2016-12-04 [05] => 2016-12-05 [06] => 2016-12-06 [07] => 2016-12-07 [08] => 2016-12-08 [09] => 2016-12-09 [10] => 2016-12-10 [11] => 2016-12-11 [12] => 2016-12-12 [13] => 2016-12-13 [14] => 2016-12-14 [15] => 2016-12-15 [16] => 2016-12-16 [17] => 2016-12-17 [18] => 2016-12-18 [19] => 2016-12-19 [20] => 2016-12-20 [21] => 2016-12-21 [22] => 2016-12-22 [23] => 2016-12-23 [24] => 2016-12-24 [25] => 2016-12-25 [26] => 2016-12-26 [27] => 2016-12-27 [28] => 2016-12-28 [29] => 2016-12-29 [30] => 2016-12-30 [31] => 2016-12-31 ) ) )
Output for 5.5.0 - 5.5.35, 5.6.0 - 5.6.28
Parse error: syntax error, unexpected ':', expecting '{' in /in/p2518 on line 2
Process exited with code 255.

preferences:
85.35 ms | 424 KiB | 5 Q