3v4l.org

run code in 300+ PHP versions simultaneously
<?php $myarray = [ [0, 70, 19, 0], [0, 24, 14], // note missing 4th element [0, 15, 11, 0], [0, 15, 27, 0] ]; for ($i = count($myarray) - 2; $i >= 0; --$i) { // start from 2nd last subarray, and move toward the start $max = max(count($myarray[$i]), count($myarray[$i+1])); // make sure all elements are accounted for for($k = 0; $k < $max; ++$k) { // iterate and perform subtractions / declarations $myarray[$i][$k] = ($myarray[$i][$k] ?? 0) - ($myarray[$i+1][$k] ?? 0); // declare/overwrite new values as encountered } } var_export($myarray);

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.4.120.0090.01120.73
8.4.110.0050.00422.45
8.4.100.0080.01217.94
8.4.90.0110.01117.66
8.4.80.0080.01222.37
8.4.70.0110.00917.82
8.4.60.0110.00518.68
8.4.50.0090.00717.66
8.4.40.0140.00717.64
8.4.30.0130.00620.33
8.4.20.0130.00718.06
8.4.10.0090.00026.05
8.3.250.0140.00519.02
8.3.240.0100.01017.07
8.3.230.0130.00616.68
8.3.220.0110.00717.34
8.3.210.0050.00316.65
8.3.200.0030.00516.50
8.3.190.0120.00618.25
8.3.180.0100.00716.53
8.3.170.0000.00716.53
8.3.160.0000.00916.68
8.3.150.0090.00917.09
8.3.140.0060.00317.36
8.3.130.0040.00418.37
8.3.120.0150.00420.77
8.3.110.0030.00516.51
8.3.100.0000.00816.50
8.3.90.0000.00820.34
8.3.80.0000.00919.36
8.3.70.0080.00818.30
8.3.60.0160.00616.61
8.3.50.0110.00723.59
8.3.40.0100.00718.85
8.3.30.0090.00618.67
8.3.20.0080.00024.18
8.3.10.0000.00824.66
8.3.00.0070.00026.16
8.2.290.0100.00620.66
8.2.280.0060.00418.66
8.2.270.0130.00616.66
8.2.260.0030.00518.88
8.2.250.0060.00918.18
8.2.240.0130.00617.36
8.2.230.0000.00820.94
8.2.220.0060.00337.54
8.2.210.0120.00326.77
8.2.200.0040.00418.88
8.2.190.0070.00718.29
8.2.180.0110.00425.92
8.2.170.0130.00318.83
8.2.160.0070.00722.96
8.2.150.0040.00425.66
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0050.00319.95
8.2.110.0090.00020.50
8.2.100.0080.00417.79
8.2.90.0000.00719.38
8.2.80.0030.00518.98
8.2.70.0000.00817.63
8.2.60.0030.00617.63
8.2.50.0090.00017.55
8.2.40.0040.00418.22
8.2.30.0050.00218.12
8.2.20.0040.00418.20
8.2.10.0000.00819.30
8.2.00.0030.00519.20
8.1.330.0140.00516.72
8.1.320.0130.00518.00
8.1.310.0120.00316.48
8.1.300.0130.00616.14
8.1.290.0060.00330.84
8.1.280.0070.00725.92
8.1.270.0040.00423.99
8.1.260.0080.00026.35
8.1.250.0100.00728.09
8.1.240.0110.00722.42
8.1.230.0040.00820.85
8.1.220.0080.00017.74
8.1.210.0030.00718.97
8.1.200.0060.00317.48
8.1.190.0040.00417.22
8.1.180.0040.00418.10
8.1.170.0040.00418.71
8.1.160.0080.00018.83
8.1.150.0040.00418.84
8.1.140.0040.00418.96
8.1.130.0000.00720.15
8.1.120.0040.00417.47
8.1.110.0000.00817.34
8.1.100.0040.00417.46
8.1.90.0040.00417.47
8.1.80.0000.01017.50
8.1.70.0000.00717.46
8.1.60.0030.00517.52
8.1.50.0060.00317.49
8.1.40.0040.00417.53
8.1.30.0080.00017.55
8.1.20.0000.00817.66
8.1.10.0050.00317.55
8.1.00.0040.00817.43
8.0.300.0040.00420.16
8.0.290.0030.00516.63
8.0.280.0000.00718.50
8.0.270.0100.00018.02
8.0.260.0000.00618.39
8.0.250.0040.00416.82
8.0.240.0000.00616.87
8.0.230.0030.00416.90
8.0.220.0000.00716.91
8.0.210.0050.00316.90
8.0.200.0000.00816.88
8.0.190.0040.00416.94
8.0.180.0000.00716.92
8.0.170.0060.00316.91
8.0.160.0040.00416.88
8.0.150.0000.00716.92
8.0.140.0070.00016.93
8.0.130.0040.00413.29
8.0.120.0040.00416.86
8.0.110.0040.00416.86
8.0.100.0040.00416.83
8.0.90.0030.00517.02
8.0.80.0060.01116.91
8.0.70.0000.00716.89
8.0.60.0000.00716.77
8.0.50.0000.00816.95
8.0.30.0070.01316.84
8.0.20.0070.01317.05
8.0.10.0150.00617.28
8.0.00.0040.01717.17
7.4.330.0050.00015.55
7.4.320.0030.00316.42
7.4.300.0060.00016.61
7.4.290.0050.00216.34
7.4.280.0000.00716.56
7.4.270.0000.00716.55
7.4.260.0030.00313.34
7.4.250.0030.00616.56
7.4.240.0030.00516.56
7.4.230.0000.00816.64
7.4.220.0050.00216.72
7.4.210.0040.00916.57
7.4.200.0000.00716.50
7.4.140.0130.00716.56
7.4.130.0130.00916.63
7.4.120.0180.00516.54
7.4.110.0130.01016.44
7.4.100.0150.00916.43
7.4.90.0190.00916.59
7.4.80.0180.00316.59
7.4.70.0090.01116.51
7.4.60.0120.00816.56
7.4.50.0110.00816.32
7.4.40.0110.00816.68
7.4.30.0070.01016.60
7.4.20.0030.01416.42
7.4.10.0060.01216.46
7.4.00.0120.01216.59
7.3.330.0000.00716.29
7.3.320.0000.00613.16
7.3.310.0050.00316.33
7.3.300.0070.00016.36
7.3.290.0070.01116.32
7.3.260.0110.00916.56
7.3.250.0030.01716.37
7.3.240.0130.01016.32
7.3.230.0030.01916.53
7.3.220.0100.01016.40
7.3.210.0110.01116.48
7.3.200.0140.00516.27
7.3.190.0110.00816.63
7.3.180.0080.01216.39
7.3.170.0080.01216.38
7.3.160.0070.01116.64
7.3.150.0050.01416.70
7.3.140.0060.01416.22
7.3.130.0170.00216.31
7.3.120.0050.01616.40
7.3.110.0160.01016.59
7.3.100.0090.01316.41
7.3.90.0110.00816.37
7.3.80.0150.00816.16
7.3.70.0170.00816.16
7.3.60.0120.01216.29
7.3.50.0140.00916.28
7.3.40.0230.00016.45
7.3.30.0130.00716.48
7.3.20.0090.01316.41
7.3.10.0120.00916.48
7.3.00.0140.01216.37

preferences:
28.54 ms | 403 KiB | 5 Q