3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tests = array("HIV", "Chlamydia", "Gonorrhoea"); $years = [ '2011' => false, '2012' => false, '2013' => false, '2014' => false, '2015' => false, '2016' => false, '2017' => false ]; $this_year = date('Y'); if (!array_key_exists($this_year, $years)) { // add to the array: $years[$this_year] = false; } $tests_by_year = []; $test_obj = []; $obj_count = count($years); $obj_added = 0; foreach ( $tests as $value ) { foreach ($years as $year => $yval) { $tests_by_year[$value][$year] = 0; if ($obj_added < $obj_count) { $test_obj[] = new \stdClass; } $test_obj[$obj_added]["y"] = (int) $year; $obj_added++; } } var_dump($test_obj); $test_obj2 = [ 0 => new \stdClass, 1 => new \stdClass, 2 => new \stdClass, 3 => new \stdClass, 4 => new \stdClass, 5 => new \stdClass, 6 => new \stdClass, 7 => new \stdClass, 8 => new \stdClass, 9 => new \stdClass ]; $test_obj2[0]->y = (int)2011; $test_obj2[1]->y = (int)2012; $test_obj2[2]->y = (int)2013; $test_obj2[3]->y = (int)2014; $test_obj2[4]->y = (int)2015; $test_obj2[5]->y = (int)2016; $test_obj2[6]->y = (int)2017; $test_obj2[7]->y = (int)2018; $test_obj2[8]->y = (int)2019; $test_obj2[9]->y = (int)2020; var_dump($test_obj2); /* foreach ($tests_by_year as $key => $value) { $test_obj[0]->$key = $value['2011']; $test_obj[1]->$key = $value['2012']; $test_obj[2]->$key = $value['2013']; $test_obj[3]->$key = $value['2014']; $test_obj[4]->$key = $value['2015']; $test_obj[5]->$key = $value['2016']; $test_obj[6]->$key = $value['2017']; $test_obj[7]->$key = $value['2018']; $test_obj[8]->$key = $value['2019']; $test_obj[9]->$key = $value['2020']; }*/

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0070.00718.53
8.3.50.0090.00618.02
8.3.40.0070.00719.09
8.3.30.0040.01518.96
8.3.20.0040.00421.77
8.3.10.0080.00021.72
8.3.00.0090.00019.80
8.2.180.0060.00918.55
8.2.170.0040.01122.96
8.2.160.0090.00620.43
8.2.150.0060.00324.18
8.2.140.0050.00324.66
8.2.130.0000.00819.18
8.2.120.0080.00026.35
8.2.110.0090.00019.30
8.2.100.0080.00417.97
8.2.90.0100.00017.97
8.2.80.0040.00418.03
8.2.70.0000.00818.02
8.2.60.0050.00318.16
8.2.50.0000.00818.28
8.2.40.0040.00420.39
8.2.30.0040.00419.61
8.2.20.0000.00818.34
8.2.10.0020.00518.16
8.2.00.0040.00418.27
8.1.270.0080.00022.11
8.1.260.0000.01226.35
8.1.250.0000.00828.09
8.1.240.0090.00022.61
8.1.230.0080.00322.75
8.1.220.0040.00417.78
8.1.210.0040.00418.77
8.1.200.0050.00317.47
8.1.190.0080.00017.47
8.1.180.0040.00418.10
8.1.170.0060.00318.91
8.1.160.0030.00518.96
8.1.150.0000.00719.12
8.1.140.0080.00017.85
8.1.130.0000.00719.11
8.1.120.0030.00317.61
8.1.110.0040.00417.50
8.1.100.0000.00717.65
8.1.90.0000.00817.53
8.1.80.0030.00617.60
8.1.70.0030.00317.67
8.1.60.0060.00317.58
8.1.50.0000.00917.61
8.1.40.0030.00517.51
8.1.30.0000.00817.73
8.1.20.0080.00017.77
8.1.10.0070.00317.57
8.1.00.0110.00017.65
8.0.300.0000.00719.89
8.0.290.0040.00416.88
8.0.280.0070.00018.50
8.0.270.0000.00717.36
8.0.260.0000.00717.28
8.0.250.0000.00717.16
8.0.240.0050.00317.16
8.0.230.0040.00417.20
8.0.220.0050.00217.12
8.0.210.0050.00317.09
8.0.200.0070.00016.99
8.0.190.0000.00717.15
8.0.180.0000.00717.02
8.0.170.0000.01017.09
8.0.160.0040.00417.15
8.0.150.0080.00016.89
8.0.140.0000.00816.91
8.0.130.0000.00513.44
8.0.120.0000.00816.93
8.0.110.0050.00316.94
8.0.100.0040.00416.96
8.0.90.0080.00016.99
8.0.80.0000.02117.02
8.0.70.0050.00317.12
8.0.60.0040.00417.01
8.0.50.0040.00417.11
8.0.30.0090.01117.22
8.0.20.0090.01117.43
8.0.10.0030.00517.32
8.0.00.0140.00717.04
7.4.330.0040.00015.55
7.4.320.0060.00016.63
7.4.300.0000.00716.53
7.4.290.0000.01016.59
7.4.280.0050.00316.59
7.4.270.0000.00816.53
7.4.260.0040.00416.57
7.4.250.0000.00716.60
7.4.240.0030.00516.61
7.4.230.0030.00316.64
7.4.220.0050.00316.47
7.4.210.0070.00816.61
7.4.200.0030.00316.62
7.4.160.0070.01116.70
7.4.140.0090.01017.86
7.4.130.0110.00716.62
7.4.120.0100.00916.75
7.4.110.0140.00416.61
7.4.100.0070.01016.59
7.4.90.0030.01716.70
7.4.80.0120.01019.39
7.4.70.0060.01416.63
7.4.60.0030.01416.70
7.4.50.0030.00716.57
7.4.40.0130.00316.75
7.4.00.0040.01115.35
7.3.330.0000.00513.47
7.3.320.0030.00313.23
7.3.310.0000.00716.63
7.3.300.0000.00716.45
7.3.290.0000.00716.46
7.3.280.0000.01516.46
7.3.260.0130.00416.45
7.3.240.0100.00916.63
7.3.230.0030.01316.63
7.3.210.0070.01016.71
7.3.200.0100.01016.66
7.3.190.0060.01016.80
7.3.180.0090.00616.50
7.3.170.0190.00616.77
7.3.160.0150.00616.57
7.2.330.0090.01316.80
7.2.320.0120.00616.58
7.2.310.0040.01516.95
7.2.300.0060.01216.88
7.2.290.0120.01216.66
7.2.60.0100.00017.04
7.2.40.0630.00918.10
7.2.30.0690.01418.24
7.2.20.0640.01217.88
7.2.10.0600.00917.74
7.2.00.0630.01218.21
7.1.200.0040.00715.94
7.1.160.1900.01416.70
7.1.150.0760.01216.80
7.1.140.0520.01316.88
7.1.130.0470.00816.74
7.1.120.0690.01317.08
7.1.110.0410.00816.38
7.1.100.0510.00816.44
7.1.90.0690.01316.49
7.1.80.0610.01816.40
7.1.70.0800.00815.33
7.1.60.0580.01833.13
7.1.50.0620.01832.95
7.1.40.0640.01332.59
7.1.30.0650.01332.86
7.1.20.0610.01932.97
7.1.10.0530.01514.94
7.1.00.0800.01415.02

preferences:
49.47 ms | 400 KiB | 5 Q