3v4l.org

run code in 300+ PHP versions simultaneously
<?php $basket = [ [ 'name' => 'apple', 'qty' => 5, ], [ 'name' => 'apple', 'qty' => 4, ], [ 'name' => 'pear', 'qty' => 4, ] ]; // need a function that would convert this to $output = []; foreach ($basket as $item) { $key = $item['name']; if (!isset($output[$key])) $output[$key] = 0; $output[$key] += $item['qty']; } var_dump($output); //$output = [['name' => 'apple', 'qty' => 9], ['name' => 'pear', 'qty' => 4]];

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.20.0030.00718.74
8.4.10.0030.00617.65
8.3.140.0000.01816.78
8.3.130.0100.00018.47
8.3.120.0100.00018.85
8.3.110.0090.00916.63
8.3.100.0050.00524.06
8.3.90.0090.00026.77
8.3.80.0090.00017.97
8.3.70.0110.00416.50
8.3.60.0140.00018.30
8.3.50.0080.00617.22
8.3.40.0110.00718.78
8.3.30.0070.01418.71
8.3.20.0080.00018.91
8.3.10.0080.00023.56
8.3.00.0120.00622.35
8.2.260.0040.00416.63
8.2.250.0030.00618.29
8.2.240.0060.00316.98
8.2.230.0080.00320.94
8.2.220.0040.00437.54
8.2.210.0030.00626.77
8.2.200.0000.01116.75
8.2.190.0130.00616.63
8.2.180.0070.00718.35
8.2.170.0140.00022.96
8.2.160.0120.00920.39
8.2.150.0000.00725.66
8.2.140.0000.00724.66
8.2.130.0110.00319.76
8.2.120.0080.00026.35
8.2.110.0060.00320.47
8.2.100.0120.00017.71
8.2.90.0060.00317.91
8.2.80.0050.00317.97
8.2.70.0000.00917.93
8.2.60.0050.00318.09
8.2.50.0060.00318.10
8.2.40.0000.00819.20
8.2.30.0040.00419.38
8.2.20.0090.00018.10
8.2.10.0050.00219.44
8.2.00.0040.00417.59
8.1.310.0150.00016.00
8.1.300.0060.01320.28
8.1.290.0080.00418.88
8.1.280.0100.01025.92
8.1.270.0060.00322.07
8.1.260.0050.00226.35
8.1.250.0000.00728.09
8.1.240.0120.00622.60
8.1.230.0070.00420.97
8.1.220.0080.00017.91
8.1.210.0000.00918.77
8.1.200.0050.00517.35
8.1.190.0040.00417.35
8.1.180.0040.00418.10
8.1.170.0050.00318.61
8.1.160.0040.00418.77
8.1.150.0000.00818.88
8.1.140.0000.00722.05
8.1.130.0000.00817.41
8.1.120.0050.00317.35
8.1.110.0070.00317.38
8.1.100.0070.00017.47
8.1.90.0030.00317.50
8.1.80.0000.00717.46
8.1.70.0000.01017.35
8.1.60.0000.00817.59
8.1.50.0000.00817.48
8.1.40.0050.00317.44
8.1.30.0000.00817.62
8.1.20.0000.00817.62
8.1.10.0040.00417.51
8.1.00.0000.00717.46
8.0.300.0040.00420.04
8.0.290.0030.00616.75
8.0.280.0000.00718.49
8.0.270.0000.00717.31
8.0.260.0000.00616.74
8.0.250.0000.00716.83
8.0.240.0030.00316.87
8.0.230.0060.00316.99
8.0.220.0070.00016.91
8.0.210.0070.00016.93
8.0.200.0040.00416.96
8.0.190.0000.00716.97
8.0.180.0050.00316.90
8.0.170.0000.00916.90
8.0.160.0070.00416.99
8.0.150.0050.00216.82
8.0.140.0040.00416.86
8.0.130.0050.00013.33
8.0.120.0070.00016.87
8.0.110.0030.00616.71
8.0.100.0030.00416.85
8.0.90.0000.00816.71
8.0.80.0080.00816.87
8.0.70.0040.00416.90
8.0.60.0000.00716.77
8.0.50.0080.00016.91
8.0.30.0120.00617.14
8.0.20.0110.00817.40
8.0.10.0000.00716.98
8.0.00.0170.00716.75
7.4.330.0060.00015.55
7.4.320.0000.00616.46
7.4.300.0060.00016.54
7.4.290.0040.00416.48
7.4.280.0030.00516.52
7.4.270.0070.00416.42
7.4.260.0030.00316.48
7.4.250.0000.00716.59
7.4.240.0030.00316.58
7.4.230.0050.00216.71
7.4.220.0070.00016.57
7.4.210.0110.00616.61
7.4.200.0000.00816.61
7.4.160.0100.01016.71
7.4.140.0140.00617.86
7.4.130.0030.02016.65
7.4.120.0090.01016.54
7.4.110.0090.00916.54
7.4.100.0100.00716.38
7.4.90.0070.01016.50
7.4.80.0030.01319.39
7.4.70.0030.01616.55
7.4.60.0030.01316.50
7.4.50.0040.01116.73
7.4.40.0060.01016.44
7.4.10.0070.00714.99
7.4.00.0070.00914.89
7.3.330.0050.00013.17
7.3.320.0050.00013.25
7.3.310.0030.00316.18
7.3.300.0070.00016.37
7.3.290.0070.00016.38
7.3.280.0090.00616.23
7.3.260.0140.00616.52
7.3.240.0120.00516.46
7.3.230.0120.00616.41
7.3.210.0090.01316.52
7.3.200.0130.00316.27
7.3.190.0110.01116.47
7.3.180.0240.01216.62
7.3.170.0110.01416.50
7.3.160.0160.00316.36
7.3.130.0030.01614.84
7.3.120.0060.01214.78
7.3.110.0060.01314.83
7.3.100.0000.01315.09
7.3.90.0030.01114.91
7.3.80.0100.00315.00
7.3.70.0080.00014.75
7.3.60.0040.01214.84
7.3.50.0070.00714.84
7.3.40.0040.00714.78
7.3.30.0040.01114.95
7.3.20.0070.00716.61
7.3.10.0060.00816.71
7.3.00.0100.00216.79
7.2.330.0080.01916.55
7.2.320.0100.00716.87
7.2.310.0070.01016.63
7.2.300.0040.01216.57
7.2.290.0150.00816.74
7.2.260.0070.01015.00
7.2.250.0070.01114.92
7.2.240.0000.01614.90
7.2.230.0040.00715.21
7.2.220.0070.01015.10
7.2.210.0060.00615.03
7.2.200.0120.00015.20
7.2.190.0090.00615.29
7.2.180.0060.00915.25
7.2.170.0030.01015.23
7.2.160.0040.01115.22
7.2.150.0000.01216.91
7.2.140.0100.00616.77
7.2.130.0060.00816.65
7.2.120.0080.00816.84
7.2.110.0620.00816.09
7.2.100.0650.00916.18
7.2.90.0610.00616.22
7.2.80.0780.00516.05
7.2.70.0690.00816.35
7.2.60.0770.00916.29
7.2.50.1050.01216.30
7.2.40.0670.00616.32
7.2.30.0790.00816.33
7.2.20.0870.00916.22
7.2.10.0850.00816.25
7.2.00.0800.00816.34
7.1.330.0030.01215.86
7.1.320.0040.01215.91
7.1.310.0000.01115.96
7.1.300.0060.01015.94
7.1.290.0000.01616.00
7.1.280.0070.00715.82
7.1.270.0030.00615.85
7.1.260.0070.00315.82
7.1.250.0050.01115.66
7.1.240.0040.00715.84
7.1.230.0680.00914.78
7.1.220.0580.01214.90
7.1.210.0610.00814.82
7.1.200.1200.00814.91
7.1.190.1460.00714.78
7.1.180.1040.01014.91
7.1.170.1040.00314.89
7.1.160.0990.00514.84
7.1.150.1060.00614.96
7.1.140.1000.00514.90
7.1.130.1040.00514.84
7.1.120.1130.01014.69
7.1.110.1450.00914.89
7.1.100.1240.00214.69
7.1.90.1210.01114.85
7.1.80.1190.00714.90
7.1.70.1150.00914.75
7.1.60.1290.01023.65
7.1.50.1550.00923.89
7.1.40.1700.01323.77
7.1.30.1710.00923.59
7.1.20.1860.01223.97
7.1.10.1290.00314.71
7.1.00.0710.00714.93
7.0.330.0030.01015.38
7.0.320.0040.01115.29
7.0.310.0050.00515.34
7.0.300.0070.00715.37
7.0.290.0100.00315.36
7.0.280.0050.00315.36
7.0.270.0000.01215.44
7.0.260.0090.00015.31
7.0.250.0030.00915.46
7.0.240.0030.01215.24
7.0.230.0000.01115.23
7.0.220.0040.00815.44
7.0.210.0030.01015.44
7.0.200.0060.00915.48
7.0.190.0110.00415.48
7.0.180.0000.01515.18
7.0.170.0060.00615.57
7.0.160.0040.00415.45
7.0.150.0060.00615.14
7.0.140.0090.00315.37
7.0.130.0080.00015.06
7.0.120.0030.01015.34
7.0.110.0030.00915.56
7.0.100.0050.00515.34
7.0.90.0070.00715.32
7.0.80.0030.00515.55
7.0.70.0040.00415.17
7.0.60.0060.00915.39
7.0.50.0030.01315.30
7.0.40.0040.01213.61
7.0.30.0000.00813.63
7.0.20.0080.00413.37
7.0.10.0000.00913.41
7.0.00.0000.01113.37
5.6.400.0000.00814.79
5.6.390.0170.00014.02
5.6.380.0030.00914.46
5.6.370.0120.00314.79
5.6.360.0060.00314.29
5.6.350.0040.00914.39
5.6.340.0070.00714.36
5.6.330.0030.01014.41
5.6.320.0000.01214.46
5.6.310.0030.00614.16
5.6.300.0030.00614.65
5.6.290.0030.01014.16
5.6.280.0050.00314.82
5.6.270.0100.01014.31
5.6.260.0060.00814.24
5.6.250.0120.00314.22
5.6.240.0070.00714.36
5.6.230.0060.00314.69
5.6.220.0030.01014.64
5.6.210.0060.00914.42
5.6.200.0040.00714.33
5.6.190.0070.01014.23
5.6.180.0040.01114.41
5.6.170.0040.00814.43
5.6.160.0040.01214.53
5.6.150.0000.01314.30
5.6.140.0040.01114.38
5.6.130.0080.00814.26
5.6.120.0070.00714.16
5.6.110.0030.00714.23
5.6.100.0070.00714.31
5.6.90.0030.01014.43
5.6.80.0000.01114.51
5.6.70.0070.00314.26
5.6.60.0030.01014.44
5.6.50.0070.01014.52
5.6.40.0040.00814.17
5.6.30.0070.00714.41
5.6.20.0100.00614.40
5.6.10.0070.00714.27
5.6.00.0110.00314.41

preferences:
34.58 ms | 403 KiB | 5 Q