3v4l.org

run code in 300+ PHP versions simultaneously
<?php $line_items = [ ['price' => 41.99, 'id' => 12, 'quantity' => 1], ['price' => 155.95, 'id' => 11, 'quantity' => 1], ['price' => 21, 'id' => 13, 'quantity' => 1] ]; $price_array = [ 197.94, 21.00 ]; $bucket_sum = 0; $bucket_index = 0; $result = []; foreach ($line_items as $row) { $result[$bucket_index][] = $row; $bucket_sum += $row['price']; if ($bucket_sum >= $price_array[$bucket_index]) { $bucket_sum = 0; ++$bucket_index; } } 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.4.120.0110.00824.09
8.4.110.0090.01219.75
8.4.100.0100.01118.77
8.4.90.0150.00518.71
8.4.80.0050.00618.68
8.4.70.0040.00518.14
8.4.60.0110.00918.94
8.4.50.0050.00818.62
8.4.40.0120.00920.71
8.4.30.0100.01020.65
8.4.20.0100.01019.59
8.4.10.0090.00623.98
8.3.250.0080.01119.17
8.3.240.0080.00717.11
8.3.230.0090.00917.36
8.3.220.0060.00218.97
8.3.210.0090.00916.39
8.3.200.0050.00416.79
8.3.190.0030.00517.30
8.3.180.0030.00517.10
8.3.170.0070.01020.59
8.3.160.0140.00416.57
8.3.150.0070.01117.11
8.3.140.0040.00416.58
8.3.130.0080.00018.32
8.3.120.0040.00418.94
8.3.110.0060.00320.94
8.3.100.0080.00016.78
8.3.90.0120.00926.77
8.3.80.0000.00918.23
8.3.70.0070.01418.40
8.3.60.0140.00718.30
8.3.50.0070.01316.43
8.3.40.0030.01620.29
8.3.30.0130.00718.79
8.3.20.0080.00024.18
8.3.10.0000.00724.66
8.3.00.0040.00426.16
8.2.290.0140.00420.57
8.2.280.0090.00918.25
8.2.270.0090.00917.41
8.2.260.0080.00016.54
8.2.250.0080.00016.25
8.2.240.0050.00318.91
8.2.230.0080.00022.58
8.2.220.0080.00024.06
8.2.210.0030.00626.77
8.2.200.0030.00616.63
8.2.190.0040.01118.41
8.2.180.0070.01025.92
8.2.170.0140.00719.13
8.2.160.0120.00322.96
8.2.150.0080.00025.66
8.2.140.0030.00624.66
8.2.130.0050.00326.16
8.2.120.0040.00426.16
8.2.110.0090.00021.12
8.2.100.0130.00017.91
8.2.90.0000.00820.46
8.2.80.0050.00320.36
8.2.70.0080.00017.50
8.2.60.0050.00318.05
8.2.50.0050.00518.07
8.2.40.0080.00018.29
8.2.30.0080.00018.13
8.2.20.0160.00017.62
8.2.10.0060.00617.64
8.2.00.0030.01017.60
8.1.330.0140.00521.83
8.1.320.0080.01218.39
8.1.310.0070.01416.01
8.1.300.0130.00618.49
8.1.290.0040.00830.84
8.1.280.0140.00025.92
8.1.270.0050.00324.66
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0040.00422.19
8.1.230.0080.00420.79
8.1.220.0080.00017.74
8.1.210.0030.00518.89
8.1.200.0060.00317.35
8.1.190.0030.00717.22
8.1.180.0050.00318.10
8.1.170.0060.00318.53
8.1.160.0000.00718.89
8.1.150.0130.00017.39
8.1.140.0000.01417.53
8.1.130.0110.00217.34
8.1.120.0090.00517.43
8.1.110.0070.00717.55
8.1.100.0070.01017.47
8.1.90.0050.01017.43
8.1.80.0130.00317.48
8.1.70.0060.00917.46
8.1.60.0090.00917.59
8.1.50.0120.00617.53
8.1.40.0180.00017.51
8.1.30.0180.00017.57
8.1.20.0100.01017.62
8.1.10.0170.00017.47
8.1.00.0090.00917.47
8.0.300.0000.00720.08
8.0.290.0030.00616.75
8.0.280.0000.00718.45
8.0.270.0080.00816.80
8.0.260.0090.00616.73
8.0.250.0090.00916.78
8.0.240.0100.00616.80
8.0.230.0160.00016.91
8.0.220.0100.00316.64
8.0.210.0100.00516.64
8.0.200.0170.00016.93
8.0.190.0150.00216.92
8.0.180.0120.00316.87
8.0.170.0090.00616.83
8.0.160.0080.00816.79
8.0.150.0050.01016.79
8.0.140.0110.00416.79
8.0.130.0100.00516.69
8.0.120.0130.00316.80
8.0.110.0170.00016.84
8.0.100.0140.00016.78
8.0.90.0040.00816.62
8.0.80.0100.00316.72
8.0.70.0080.00416.73
8.0.60.0050.00516.71
8.0.50.0040.00416.60
8.0.30.0090.00216.82
8.0.20.0080.00516.86
8.0.10.0090.00216.93

preferences:
29.48 ms | 403 KiB | 5 Q