3v4l.org

run code in 300+ PHP versions simultaneously
<?php $items = [ [ 'qty' => 1, 'weight' => 1, ], [ 'qty' => 2, 'weight' => 1, ], [ 'qty' => 3, 'weight' => 1, ], [ 'qty' => 1, 'weight' => 5, ], ]; $weights = array_column($items, 'weight'); $result =0; Foreach(array_unique($weights) as $weight){ $weightitems = preg_grep("/". $weight . "/", $weights); $result += array_sum(array_column(array_intersect_key($items, $weightitems), "qty")) * $weight; } Echo $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.3.70.0140.00016.63
8.3.60.0130.01018.68
8.3.50.0000.01418.18
8.3.40.0120.00619.00
8.3.30.0110.01118.97
8.3.20.0000.00721.91
8.3.10.0070.00021.90
8.3.00.0040.00423.61
8.2.190.0040.01116.63
8.2.180.0040.01218.75
8.2.170.0070.00718.91
8.2.160.0120.00322.96
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0040.00421.04
8.2.120.0040.00426.35
8.2.110.0070.00321.11
8.2.100.0030.00917.97
8.2.90.0030.00619.02
8.2.80.0030.00517.97
8.2.70.0050.00317.75
8.2.60.0000.00817.88
8.2.50.0030.00618.00
8.2.40.0050.00519.48
8.2.30.0040.00421.15
8.2.20.0040.00418.14
8.2.10.0030.00618.02
8.2.00.0040.00419.32
8.1.280.0140.00325.92
8.1.270.0080.00022.07
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0100.00019.53
8.1.230.0060.00617.89
8.1.220.0040.00417.79
8.1.210.0040.00418.77
8.1.200.0100.00017.35
8.1.190.0040.00417.36
8.1.180.0040.00418.10
8.1.170.0040.00417.62
8.1.160.0040.00418.79
8.1.150.0020.00518.93
8.1.140.0050.00217.60
8.1.130.0000.00719.05
8.1.120.0020.00517.60
8.1.110.0040.00417.58
8.1.100.0000.00717.61
8.1.90.0050.00217.59
8.1.80.0000.00717.61
8.1.70.0030.00617.58
8.1.60.0060.00317.62
8.1.50.0030.00617.66
8.1.40.0040.00417.65
8.1.30.0050.00317.79
8.1.20.0000.00717.74
8.1.10.0070.00017.65
8.1.00.0000.00817.48
8.0.300.0080.00018.77
8.0.290.0000.00816.88
8.0.280.0030.00318.46
8.0.270.0050.00217.26
8.0.260.0030.00317.21
8.0.250.0040.00417.09
8.0.240.0000.00717.10
8.0.230.0030.00316.97
8.0.220.0000.00716.94
8.0.210.0030.00616.93
8.0.200.0040.00417.10
8.0.190.0000.00817.11
8.0.180.0050.00317.08
8.0.170.0030.00617.04
8.0.160.0040.00416.92
8.0.150.0000.00717.05
8.0.140.0070.00017.00
8.0.130.0060.00013.46
8.0.120.0040.00416.95
8.0.110.0040.00416.88
8.0.100.0040.00416.94
8.0.90.0030.00517.06
8.0.80.0120.00616.98
8.0.70.0000.00816.86
8.0.60.0040.00417.07
8.0.50.0000.00717.05
8.0.30.0100.00917.31
8.0.20.0070.01117.45
8.0.10.0050.00217.19
8.0.00.0100.00716.88
7.4.330.0040.00015.55
7.4.320.0000.00616.76
7.4.300.0000.00616.82
7.4.290.0000.00716.68
7.4.280.0040.00416.77
7.4.270.0000.00716.71
7.4.260.0040.00416.73
7.4.250.0040.00416.66
7.4.240.0070.00016.79
7.4.230.0000.00716.61
7.4.220.0040.00416.91
7.4.210.0040.01016.83
7.4.200.0000.00716.64
7.4.160.0110.01016.54
7.4.140.0080.01017.86
7.4.130.0090.00916.80
7.4.120.0140.00716.76
7.4.110.0100.01316.54
7.4.100.0030.01316.74
7.4.90.0070.01116.65
7.4.80.0100.01319.39
7.4.70.0070.01016.60
7.4.60.0140.00316.64
7.4.50.0040.00716.61
7.4.40.0130.00316.81
7.4.00.0060.01115.27
7.3.330.0000.00513.39
7.3.320.0000.00613.21
7.3.310.0000.00716.34
7.3.300.0070.00016.45
7.3.290.0000.00616.40
7.3.280.0080.01016.45
7.3.260.0110.00616.54
7.3.240.0120.00816.62
7.3.230.0150.00916.44
7.3.210.0060.01216.64
7.3.200.0150.00616.66
7.3.190.0030.01516.43
7.3.180.0100.00616.32
7.3.170.0160.00016.46
7.3.160.0100.00716.51
7.3.120.0070.01015.32
7.3.110.0110.00714.86
7.3.100.0030.00914.91
7.3.90.0120.00314.88
7.3.80.0000.01414.84
7.3.70.0070.00714.90
7.3.60.0030.01014.96
7.3.50.0030.00915.00
7.3.40.0060.00914.71
7.3.30.0060.01115.00
7.3.20.0100.01016.41
7.3.10.0070.01116.57
7.3.00.0100.00716.87
7.2.330.0110.01116.86
7.2.320.0070.01117.05
7.2.310.0150.00316.80
7.2.300.0080.00816.74
7.2.290.0000.02216.70
7.2.250.0000.01815.00
7.2.240.0060.01014.93
7.2.230.0060.01515.34
7.2.220.0040.01115.23
7.2.210.0060.00915.30
7.2.200.0100.00615.10
7.2.190.0060.01014.88
7.2.180.0110.00315.32
7.2.170.0030.00715.01
7.2.60.0040.01217.07
7.2.50.0100.00717.15
7.2.40.0120.00818.29
7.2.30.6060.01317.77
7.2.20.0490.01018.00
7.2.10.0150.00618.00
7.2.00.0790.01118.19
7.1.330.0030.01015.75
7.1.320.0150.00415.91
7.1.310.0030.00715.80
7.1.300.0060.00315.72
7.1.290.0150.00016.13
7.1.280.0040.00815.93
7.1.270.0110.00315.86
7.1.260.0130.00316.09
7.1.200.0080.00015.95
7.1.160.0180.00717.01
7.1.150.4970.00917.04
7.1.140.1040.01417.21
7.1.130.0110.01416.88
7.1.120.0130.01217.26
7.1.110.0120.01516.38
7.1.100.5150.01016.61
7.1.90.7200.01016.57
7.1.80.7520.01016.26
7.1.70.5920.00815.57
7.1.60.3040.01433.50
7.1.50.0310.01033.16
7.1.40.0350.01732.94
7.1.30.0560.01632.99
7.1.20.0340.02032.89
7.1.10.0110.01215.12
7.1.00.0130.01415.05

preferences:
19.12 ms | 401 KiB | 5 Q