3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ 2 => 5, 4 => 1, 8 => 3, 0 => 17, 9 => 2, 11 => 67 ]; $ranges = [ '1-5' => ['min' => 1, 'max' => 5], '6-10' => ['min' => 6, 'max' => 10], '1000-5000' => ['min' => 1000, 'max' => 5000], ]; $result = array_map(fn() => 0, $ranges); foreach ($array as $num => $amount) { foreach ($ranges as $rangeName => ['min' => $min, 'max' => $max]) { if ($num >= $min && $num <= $max) { $result[$rangeName] += $amount; break; } } } var_export($result);

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.5.70.0100.01118.50
8.5.60.0090.00716.71
8.5.50.0060.00316.59
8.5.30.0090.00819.59
8.5.20.0100.00719.38
8.5.10.0140.00420.16
8.5.00.0120.00919.94
8.4.220.0100.01025.78
8.4.210.0050.00519.61
8.4.180.0130.00919.69
8.4.170.0130.00823.97
8.4.160.0130.01122.97
8.4.150.0100.00416.92
8.4.140.0140.00717.78
8.4.130.0110.00617.68
8.4.120.0090.00922.33
8.4.110.0150.00517.77
8.4.100.0080.00818.49
8.4.90.0130.00818.81
8.4.80.0140.00617.92
8.4.70.0090.01417.71
8.4.60.0060.00218.85
8.4.50.0090.01120.54
8.4.40.0130.00617.96
8.4.30.0100.01018.62
8.4.20.0070.01322.70
8.4.10.0060.00323.88
8.3.300.0130.00719.20
8.3.290.0080.01222.60
8.3.280.0130.00918.39
8.3.270.0080.01116.36
8.3.260.0110.00816.86
8.3.250.0110.00818.97
8.3.240.0110.00317.20
8.3.230.0050.00516.74
8.3.220.0050.00517.13
8.3.210.0060.00120.84
8.3.200.0020.00616.63
8.3.190.0040.00417.21
8.3.180.0110.00818.55
8.3.170.0120.00617.01
8.3.160.0170.00318.55
8.3.150.0040.01118.46
8.3.140.0080.00017.10
8.3.130.0160.00018.45
8.3.120.0100.00018.91
8.3.110.0030.00620.94
8.3.100.0040.00416.60
8.3.90.0090.00926.77
8.3.80.0110.00016.75
8.3.70.0110.00716.58
8.3.60.0070.00718.68
8.3.50.0100.00618.13
8.3.40.0040.01120.13
8.3.30.0140.00018.81
8.3.20.0000.00824.18
8.3.10.0040.00424.66
8.3.00.0070.00026.16
8.2.300.0120.00820.31
8.2.290.0110.00820.36
8.2.280.0100.00518.37
8.2.270.0100.00716.99
8.2.260.0000.01416.58
8.2.250.0100.01016.50
8.2.240.0040.01217.14
8.2.230.0050.00322.58
8.2.220.0050.00524.06
8.2.210.0000.00826.77
8.2.200.0060.00318.41
8.2.190.0150.00416.58
8.2.180.0090.00925.92
8.2.170.0130.00318.95
8.2.160.0100.00322.96
8.2.150.0000.00925.66
8.2.140.0000.00724.66
8.2.130.0040.00426.16
8.2.120.0040.00426.16
8.2.110.0080.01520.89
8.2.100.0090.00317.91
8.2.90.0030.00517.75
8.2.80.0060.00318.77
8.2.70.0060.00317.75
8.2.60.0040.00417.63
8.2.50.0040.00418.04
8.2.40.0060.00318.34
8.2.30.0030.00518.12
8.2.20.0000.00719.25
8.2.10.0040.00718.20
8.2.00.0000.00719.36
8.1.340.0130.00717.63
8.1.330.0110.00721.98
8.1.320.0080.01016.39
8.1.310.0150.00318.32
8.1.300.0040.00417.94
8.1.290.0060.00330.84
8.1.280.0110.00425.92
8.1.270.0080.00024.66
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0070.00423.64
8.1.230.0000.01121.04
8.1.220.0080.00018.51
8.1.210.0040.00419.16
8.1.200.0040.00417.22
8.1.190.0000.00817.36
8.1.180.0040.00418.10
8.1.170.0050.00317.62
8.1.160.0040.00418.84
8.1.150.0000.00718.70
8.1.140.0030.00617.39
8.1.130.0000.00718.90
8.1.120.0030.00317.43
8.1.110.0050.00517.45
8.1.100.0050.01117.40
8.1.90.0130.00217.44
8.1.80.0100.00517.44
8.1.70.0120.00517.42
8.1.60.0140.00317.45
8.1.50.0050.01417.53
8.1.40.0120.00017.48
8.1.30.0070.00717.67
8.1.20.0120.00417.63
8.1.10.0150.00517.55
8.1.00.0150.00317.50
8.0.300.0040.00419.97
8.0.290.0050.00316.58
8.0.280.0070.00018.28
8.0.270.0070.00017.27
8.0.260.0030.00318.44
8.0.250.0000.00716.97
8.0.240.0080.00216.85
8.0.230.0140.00016.88
8.0.220.0050.01016.86
8.0.210.0070.00716.74
8.0.200.0150.00016.79
8.0.190.0100.00616.91
8.0.180.0160.00016.86
8.0.170.0160.00016.93
8.0.160.0090.00616.91
8.0.150.0070.00716.67
8.0.140.0140.00016.77
8.0.130.0120.00316.60
8.0.120.0040.01116.83
8.0.110.0110.00416.68
8.0.100.0070.00716.87
8.0.90.0160.00016.82
8.0.80.0110.00416.78
8.0.70.0140.00216.66
8.0.60.0070.00716.85
8.0.50.0170.00016.71
8.0.30.0100.00616.86
8.0.20.0080.00816.89
8.0.10.0120.00316.91
7.4.330.0000.00515.55
7.4.320.0100.00716.62
7.4.300.0080.00016.50
7.4.290.0100.00016.55
7.4.280.0070.00716.40
7.4.270.0110.00416.57
7.4.260.0120.00316.57
7.4.250.0110.00316.47
7.4.240.0080.00816.46
7.4.230.0100.00316.50
7.4.220.0060.00916.58
7.4.210.0050.00916.46
7.4.200.0120.00216.34
7.4.190.0080.00616.67
7.4.180.0110.00316.55
7.4.160.0120.00216.55
7.4.150.0140.00016.33
7.4.140.0090.00616.45
7.4.130.0100.00716.45
7.4.120.0100.00716.38
7.4.110.0130.00316.43
7.4.100.0080.00016.49
7.4.90.0050.00916.40
7.4.80.0100.00516.34
7.4.70.0130.00316.46
7.4.60.0100.00416.48
7.4.50.0140.00016.34
7.4.40.0100.00516.39
7.4.30.0070.00716.41
7.4.20.0090.00516.46
7.4.10.0110.00316.46
7.4.00.0070.00716.37

preferences:
104.35 ms | 1263 KiB | 5 Q