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 = []; foreach ($ranges as $rangeName => ['min' => $min, 'max' => $max]) { $result[$rangeName] = 0; foreach ($array as $num => $amount) { if ($num < $min) { unset($array[$num]); } elseif ($num <= $max) { $result[$rangeName] += $amount; unset($array[$num]); } } } 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.0050.00316.67
8.5.60.0130.00416.64
8.5.50.0110.00216.75
8.5.30.0130.00617.91
8.5.20.0110.01120.18
8.5.10.0100.00816.69
8.5.00.0130.00819.73
8.4.220.0110.01119.53
8.4.210.0070.00419.65
8.4.180.0120.01119.82
8.4.170.0120.00924.05
8.4.160.0110.01023.94
8.4.150.0080.00616.89
8.4.140.0170.00417.44
8.4.130.0140.00717.82
8.4.120.0130.00720.57
8.4.110.0100.00722.30
8.4.100.0140.00717.60
8.4.90.0120.00718.39
8.4.80.0050.00317.75
8.4.70.0090.01217.87
8.4.60.0140.00618.84
8.4.50.0080.00818.55
8.4.40.0130.00617.55
8.4.30.0460.00317.49
8.4.20.0420.01017.49
8.4.10.0340.01417.41
8.3.300.0120.01020.86
8.3.290.0120.00918.43
8.3.280.0110.01018.43
8.3.270.0120.00716.51
8.3.260.0100.00916.50
8.3.250.0120.00419.09
8.3.240.0060.00417.18
8.3.230.0110.00916.66
8.3.220.0080.00717.19
8.3.210.0080.01116.85
8.3.200.0040.00416.68
8.3.190.0110.00617.14
8.3.180.0110.00720.61
8.3.170.0060.00916.95
8.3.160.0460.00016.66
8.3.150.0280.01816.45
8.3.140.0370.00916.49
8.3.130.0310.00616.71
8.3.120.0340.00316.63
8.3.110.0340.00616.71
8.3.100.0320.01416.23
8.3.90.0390.00716.37
8.3.80.0380.00716.57
8.3.70.0350.01716.46
8.3.60.0380.01316.38
8.3.50.0390.00716.56
8.3.40.0360.00417.17
8.3.30.0270.01017.29
8.3.20.0300.00717.28
8.3.10.0250.01117.43
8.3.00.0210.00017.41
8.2.300.0100.00918.12
8.2.290.0040.00620.30
8.2.280.0080.00618.45
8.2.270.0350.00316.42
8.2.260.0240.01216.50
8.2.250.0320.00516.50
8.2.240.0290.00916.29
8.2.230.0290.00916.20
8.2.220.0300.00816.33
8.2.210.0330.00616.30
8.2.200.0310.00616.11
8.2.190.0280.00916.57
8.2.180.0240.01416.23
8.2.170.0430.00717.64
8.2.160.0420.00417.45
8.2.150.0320.00817.65
8.2.140.0380.00317.34
8.2.130.0280.01217.59
8.2.120.0310.00917.55
8.2.110.0280.01217.61
8.2.100.0250.01417.65
8.2.90.0300.01217.56
8.2.80.0350.00717.28
8.2.70.0280.01117.33
8.2.60.0290.01017.45
8.2.50.0350.01117.52
8.2.40.0330.00917.27
8.2.30.0280.00917.26
8.2.20.0320.00417.57
8.2.10.0320.01117.54
8.2.00.0300.00417.31
8.1.340.0110.00917.52
8.1.320.0080.01116.37

preferences:
59.22 ms | 862 KiB | 5 Q