3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['id' => 'abc-abc-12', 'qty' => 0, 'locationID' => 276, 'CC_qty' => 250, 'Location' => 'NOP11'], ['id' => 'abc-abc-12', 'qty' => 0, 'locationID' => 310, 'CC_qty' => 1385, 'Location' => 'NOP01'], ['id' => 'abc-abc-23', 'qty' => 0, 'locationID' => 84, 'CC_qty' => 116, 'Location' => 'NOP06'], ['id' => 'abc-abc-23', 'qty' => 0, 'locationID' => 254, 'CC_qty' => 432, 'Location' => 'NOP08'], ['id' => 'abc-abc-23', 'qty' => 0, 'locationID' => 228, 'CC_qty' => 101, 'Location' => 'NOP04'], ['id' => 'abc-abc-34', 'qty' => 0, 'locationID' => 254, 'CC_qty' => 436, 'Location' => 'NOP08'], ['id' => 'abc-abc-34', 'qty' => 0, 'locationID' => 254, 'CC_qty' => 62, 'Location' => 'NOP08'], ['id' => 'abc-abc-45', 'qty' => 0, 'locationID' => 75, 'CC_qty' => 89, 'Location' => 'NOP05'], ['id' => 'abc-abc-45', 'qty' => 0, 'locationID' => 202, 'CC_qty' => 372, 'Location' => 'NOP07'], ]; $result = []; foreach ($array as $row) { if (!isset($result[$row['id']])) { $result[$row['id']] = $row; } else { $result[$row['id']]['qty'] += $row['qty']; // SUM $result[$row['id']]['locationID'] .= ", " . $row['locationID']; // CONCAT $result[$row['id']]['CC_qty'] += $row['CC_qty']; // SUM $result[$row['id']]['Location'] .= ", " . $row['Location']; // CONCAT } } var_export(array_values($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.140.0110.01117.54
8.4.130.0130.00817.85
8.4.120.0130.00720.64
8.4.110.0140.00522.52
8.4.100.0130.00717.67
8.4.90.0110.00920.39
8.4.80.0050.00419.16
8.4.70.0100.00919.07
8.4.60.0140.00718.67
8.4.50.0130.00718.77
8.4.40.0040.01817.82
8.4.30.0150.00020.62
8.4.20.0100.01017.88
8.4.10.0000.00921.50
8.3.270.0100.00916.52
8.3.260.0100.00916.53
8.3.250.0150.00319.00
8.3.240.0060.00216.85
8.3.230.0110.00816.48
8.3.220.0040.00319.03
8.3.210.0080.01116.69
8.3.200.0040.00516.80
8.3.190.0030.00517.05
8.3.180.0120.00716.69
8.3.170.0110.00318.88
8.3.160.0060.01217.25
8.3.150.0110.00717.11
8.3.140.0000.00816.73
8.3.130.0040.00418.28
8.3.120.0030.00620.58
8.3.110.0040.00416.74
8.3.100.0040.01124.06
8.3.90.0060.00326.77
8.3.80.0070.00319.36
8.3.70.0040.01116.75
8.3.60.0110.00416.50
8.3.50.0090.00824.42
8.3.40.0070.01118.80
8.3.30.0040.01118.75
8.3.20.0000.00724.18
8.3.10.0080.00024.66
8.3.00.0000.00826.16
8.2.290.0120.00716.86
8.2.280.0110.00818.28
8.2.270.0070.01017.24
8.2.260.0120.00318.90
8.2.250.0000.00818.45
8.2.240.0000.00917.17
8.2.230.0050.00320.94
8.2.220.0000.00937.54
8.2.210.0150.00626.77
8.2.200.0060.00318.88
8.2.190.0150.00016.58
8.2.180.0130.00325.92
8.2.170.0110.00419.13
8.2.160.0070.00722.96
8.2.150.0070.00025.66
8.2.140.0000.00724.66
8.2.130.0040.00426.16
8.2.120.0040.00421.07
8.2.110.0080.00422.16
8.2.100.0200.00417.64
8.2.90.0030.00519.27
8.2.80.0080.00017.97
8.2.70.0030.00617.63
8.2.60.0030.00517.93
8.2.50.0040.00418.07
8.2.40.0070.00018.22
8.2.30.0000.00717.99
8.2.20.0040.00418.22
8.2.10.0040.00419.22
8.2.00.0030.00519.33
8.1.330.0100.00916.19
8.1.320.0100.00918.02
8.1.310.0070.01116.67
8.1.300.0090.00018.51
8.1.290.0060.00330.84
8.1.280.0120.00925.92
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0000.00920.93
8.1.230.0040.00719.08
8.1.220.0040.00417.77
8.1.210.0050.00318.77
8.1.200.0080.00317.47
8.1.190.0000.00817.23
8.1.180.0000.00818.10
8.1.170.0080.00018.90
8.1.160.0040.00418.96
8.1.150.0060.00318.85
8.1.140.0000.00718.86
8.1.130.0000.00720.29
8.1.120.0000.00717.53
8.1.110.0000.00717.52
8.1.100.0030.00617.47
8.1.90.0000.00717.39
8.1.80.0030.00517.44
8.1.70.0030.00317.46
8.1.60.0030.00517.62
8.1.50.0000.00817.57
8.1.40.0060.00317.58
8.1.30.0000.00817.67
8.1.20.0040.00417.68
8.1.10.0040.00417.50
8.1.00.0040.00417.49
8.0.300.0000.00818.77
8.0.290.0030.00716.75
8.0.280.0000.00718.48
8.0.270.0040.00418.05
8.0.260.0080.00018.53
8.0.250.0040.00416.96
8.0.240.0030.00316.96
8.0.230.0040.00417.01
8.0.220.0000.00716.92
8.0.210.0030.00316.82
8.0.200.0030.00317.00
8.0.190.0060.00316.89
8.0.180.0050.00316.96
8.0.170.0040.00416.97
8.0.160.0000.00816.85
8.0.150.0000.00816.89
8.0.140.0000.00716.86
8.0.130.0030.00313.40
8.0.120.0050.00316.82
8.0.110.0030.00516.79
8.0.100.0000.00716.81
8.0.90.0040.00416.84
8.0.80.0110.00816.87
8.0.70.0000.00716.84
8.0.60.0080.00016.99
8.0.50.0000.00916.97
8.0.30.0110.00616.98
8.0.20.0220.02817.04
8.0.10.0000.00716.85
8.0.00.0100.01016.79
7.4.330.0030.00315.55
7.4.320.0030.00316.56
7.4.300.0030.00316.56
7.4.290.0000.00716.68
7.4.280.0040.00416.45
7.4.270.0000.00716.44
7.4.260.0000.00513.27
7.4.250.0080.00016.52
7.4.240.0040.00416.63
7.4.230.0000.00716.74
7.4.220.0030.00316.56
7.4.210.0080.00716.63
7.4.200.0000.00716.34
7.4.130.0120.00516.58
7.4.120.0090.00916.45
7.4.110.0090.00916.55
7.4.100.0060.01016.50
7.4.90.0060.01116.69
7.4.80.0060.01319.39
7.4.70.0130.00416.46
7.4.60.0080.01316.39
7.4.50.0120.00616.46
7.4.40.0140.00316.41
7.4.30.0030.01616.42
7.4.20.0130.00316.23
7.4.10.0060.01216.46
7.4.00.0110.00616.80
7.3.330.0040.00416.16
7.3.320.0000.00613.12
7.3.310.0000.00716.42
7.3.300.0040.00416.20
7.3.290.0100.00416.30
7.3.260.0120.01216.30
7.3.230.0130.01016.44
7.3.210.0130.01016.70
7.3.200.0070.01016.49
7.3.190.0090.01416.31
7.3.180.0170.00516.30
7.3.170.0150.00316.25
7.3.160.0200.00016.47
7.3.150.0130.00816.14
7.3.140.0090.00916.27
7.3.130.0120.00616.35
7.3.120.0080.01116.35
7.3.110.0150.00616.28
7.3.100.0060.01216.31
7.3.90.0070.01116.52
7.3.80.0150.00616.49
7.3.70.0140.00316.30
7.3.60.0090.01416.34
7.3.50.0110.00816.32
7.3.40.0080.01116.36
7.3.30.0050.01516.44
7.3.20.0140.01316.57
7.3.10.0130.00616.31
7.3.00.0100.01116.46
7.2.330.0120.00616.70
7.2.320.0070.01016.57
7.2.310.0090.00916.66
7.2.300.0120.00816.63
7.2.290.0110.01116.88
7.2.280.0100.01016.68
7.2.270.0120.01216.41
7.2.260.0050.01216.79
7.2.250.0050.01316.47
7.2.240.0130.01016.59
7.2.230.0090.00916.53
7.2.220.0100.00716.70
7.2.210.0030.01916.34
7.2.200.0080.01016.55
7.2.190.0030.01616.61
7.2.180.0080.01416.57
7.2.170.0190.00416.72
7.2.160.0150.00416.57
7.2.150.0000.02016.61
7.2.140.0090.01216.65
7.2.130.0100.01016.59
7.2.120.0150.00716.76
7.2.110.0090.01316.66
7.2.100.0120.00816.49
7.2.90.0070.01316.66
7.2.80.0170.00416.75
7.2.70.0130.01016.57
7.2.60.0070.01416.52
7.2.50.0160.01016.63
7.2.40.0070.01416.47
7.2.30.0060.01416.68
7.2.20.0120.00916.56
7.2.10.0100.01716.67
7.2.00.0160.00716.70

preferences:
31.06 ms | 403 KiB | 5 Q