3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [['user1' => 20], ['user2' => 30], 3 => ['user3' => 10]]; echo array_sum(array_column(array_map('array_values', $array), 0)); // reindex subarrays, isolate zero column, sum values echo "\n---\n"; array_walk_recursive($array, function($v)use(&$sum){ $sum += $v; }); // visit each leafnode, increase the $sum tally echo $sum; echo "\n---\n"; $total = 0; // without this declaration, you will generate: "Notice: Undefined variable" foreach ($array as $subarray) { foreach ($subarray as $v) { $total += $v; } } echo $total;

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.130.0080.01017.80
8.4.120.0090.01122.31
8.4.110.0070.00318.57
8.4.100.0150.00617.63
8.4.90.0080.01317.60
8.4.80.0050.00617.93
8.4.70.0140.00717.66
8.4.60.0120.00920.38
8.4.50.0150.00518.65
8.4.40.0100.01017.70
8.4.30.0130.00717.53
8.4.20.0050.00320.55
8.4.10.0030.00619.37
8.3.260.0060.00316.92
8.3.250.0060.00320.72
8.3.240.0120.00616.61
8.3.230.0070.00316.71
8.3.220.0060.00517.08
8.3.210.0070.00816.76
8.3.200.0060.00316.75
8.3.190.0080.00717.10
8.3.180.0090.00516.53
8.3.170.0110.00722.63
8.3.160.0110.00717.17
8.3.150.0090.00917.07
8.3.140.0120.00616.50
8.3.130.0030.00618.42
8.3.120.0040.01118.81
8.3.110.0050.00320.94
8.3.100.0040.00724.06
8.3.90.0070.01026.77
8.3.80.0060.00316.75
8.3.70.0160.00616.63
8.3.60.0060.00918.30
8.3.50.0090.00617.98
8.3.40.0140.00318.54
8.3.30.0070.00718.84
8.3.20.0120.00318.79
8.3.10.0080.00023.53
8.3.00.0040.00421.69
8.2.290.0050.00320.10
8.2.280.0110.00816.42
8.2.270.0040.01117.02
8.2.260.0090.00016.36
8.2.250.0090.00016.73
8.2.240.0090.00616.91
8.2.230.0120.00422.58
8.2.220.0150.00637.54
8.2.210.0210.00026.77
8.2.200.0090.00916.50
8.2.190.0090.00620.09
8.2.180.0100.01016.50
8.2.170.0110.00422.96
8.2.160.0100.00319.45
8.2.150.0080.00024.18
8.2.140.0030.00524.66
8.2.130.0040.00421.05
8.2.120.0040.00426.35
8.2.110.0030.00720.95
8.2.100.0090.00317.91
8.2.90.0060.00319.29
8.2.80.0040.00417.97
8.2.70.0000.00817.78
8.2.60.0050.00318.22
8.2.50.0080.00018.10
8.2.40.0070.00019.33
8.2.30.0040.00420.61
8.2.20.0000.00917.99
8.2.10.0000.00718.16
8.2.00.0040.00419.41
8.1.330.0080.01118.34
8.1.320.0060.01315.91
8.1.310.0040.00416.41
8.1.300.0090.00017.92
8.1.290.0040.01118.88
8.1.280.0110.00725.92
8.1.270.0040.00420.65
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0040.00423.98
8.1.230.0110.00019.08
8.1.220.0050.00217.76
8.1.210.0060.00318.77
8.1.200.0000.01017.35
8.1.190.0040.00417.10
8.1.180.0050.00318.10
8.1.170.0050.00518.56
8.1.160.0070.00018.95
8.1.150.0050.00218.80
8.1.140.0060.00320.58
8.1.130.0040.00420.34
8.1.120.0040.00317.47
8.1.110.0050.00217.43
8.1.100.0070.00317.34
8.1.90.0030.00517.46
8.1.80.0000.00817.37
8.1.70.0000.00717.48
8.1.60.0080.00017.47
8.1.50.0000.00917.49
8.1.40.0050.00217.50
8.1.30.0050.00317.67
8.1.20.0000.00717.61
8.1.10.0000.01017.50
8.1.00.0030.00517.38
8.0.300.0000.00718.77
8.0.290.0060.00316.63
8.0.280.0030.00318.52
8.0.270.0080.00017.13
8.0.260.0040.00420.18
8.0.250.0060.00016.84
8.0.240.0050.00316.89
8.0.230.0000.00716.93
8.0.220.0070.00016.84
8.0.210.0030.00316.87
8.0.200.0000.00716.93
8.0.190.0030.00517.00
8.0.180.0000.01216.89
8.0.170.0030.00616.95
8.0.160.0050.00216.90
8.0.150.0000.00716.71
8.0.140.0030.00616.77
8.0.130.0050.00213.33
8.0.120.0040.00416.73
8.0.110.0030.00516.77
8.0.100.0030.00316.82
8.0.90.0030.00516.70
8.0.80.0090.00716.88
8.0.70.0000.00716.82
8.0.60.0030.00516.88
8.0.50.0000.00716.96
8.0.30.0120.01017.13
8.0.20.0100.00917.40
8.0.10.0080.00016.79
8.0.00.0050.01316.65
7.4.330.0000.00515.55
7.4.320.0060.00016.47
7.4.300.0060.00316.39
7.4.290.0040.00416.50
7.4.280.0030.00416.57
7.4.270.0000.00816.57
7.4.260.0070.00016.48
7.4.250.0000.00716.48
7.4.240.0040.00416.45
7.4.230.0040.00416.69
7.4.220.0000.00716.66
7.4.210.0070.00716.57
7.4.200.0050.00316.42
7.4.160.0110.00616.50
7.4.140.0090.01417.86
7.4.130.0100.00716.37
7.4.120.0100.00816.47
7.4.110.0130.00316.54
7.4.100.0060.01216.42
7.4.90.0110.00716.54
7.4.80.0160.00619.39
7.4.70.0100.00616.48
7.4.60.0130.00316.57
7.4.50.0080.00816.48
7.4.40.0060.01116.40
7.4.00.0110.00315.10
7.3.330.0020.00213.33
7.3.320.0000.00613.35
7.3.310.0030.00316.41
7.3.300.0000.00716.30
7.3.290.0030.00316.21
7.3.280.0120.00716.31
7.3.260.0140.00916.50
7.3.240.0120.00516.45
7.3.230.0110.00516.66
7.3.210.0030.01316.45
7.3.200.0140.00716.40
7.3.190.0080.00816.56
7.3.180.0120.00916.27
7.3.170.0100.00716.43
7.3.160.0100.01016.55
7.3.120.0070.00414.64
7.3.110.0040.01414.88
7.3.100.0100.00714.93
7.3.90.0110.00314.54
7.3.80.0030.01014.88
7.3.70.0030.00914.67
7.3.60.0030.00714.86
7.3.50.0030.01014.91
7.3.40.0040.00814.59
7.3.30.0090.00614.85
7.3.20.0090.00316.61
7.3.10.0040.00816.47
7.3.00.0030.01016.82
7.2.330.0030.02116.75
7.2.320.0130.00716.54
7.2.310.0110.00616.43
7.2.300.0070.01016.52
7.2.290.0040.01316.55
7.2.250.0130.00714.99
7.2.240.0070.01415.01
7.2.230.0030.00614.96
7.2.220.0070.01015.25
7.2.210.0000.01515.20
7.2.200.0000.01614.59
7.2.190.0000.00915.18
7.2.180.0030.01314.80
7.2.170.0070.01115.07
7.2.90.2840.00914.84
7.2.80.2450.00714.74
7.2.70.2130.00014.78
7.2.60.2300.01014.96
7.2.50.2590.00915.03
7.2.40.2340.01014.80
7.2.30.2290.01314.72
7.2.20.2870.01014.58
7.2.10.2930.00614.79
7.2.00.3260.00714.92
7.1.330.0070.00616.02
7.1.320.0070.01015.80
7.1.310.0040.01115.92
7.1.300.0110.00415.78
7.1.290.0040.00815.64
7.1.280.0040.00815.61
7.1.270.0070.01015.88
7.1.260.0080.00615.74
7.1.210.0490.00013.78
7.1.200.2370.00613.90
7.1.190.4660.00713.99
7.1.180.2120.00314.05
7.1.170.2900.00713.80
7.1.160.2540.00313.51
7.1.150.2460.00713.59
7.1.140.2880.00713.63
7.1.130.2660.01013.69
7.1.120.3070.01313.99
7.1.110.2870.00713.81
7.1.100.2970.01013.61
7.1.90.3630.00613.97
7.1.80.3350.01013.90
7.1.70.4560.00313.61
7.1.60.4720.01331.53
7.1.50.5240.01931.34
7.1.40.5920.01331.96
7.1.30.5070.00931.64
7.1.20.5550.01331.57
7.1.10.6220.01313.67
7.1.00.5140.01013.93

preferences:
32.36 ms | 403 KiB | 5 Q