3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Everything you enter here will be executed by our servers. Try it! $data = array( array( 'id' => 1, 'name' => 'bob', 'product_id' => 1, 'product' => 'laptop', 'price' => 999, ), array( 'id' => 1, 'name' => 'bob', 'product_id' => 2, 'product' => 'mouse', 'price' => 15, ), array( 'id' => 1, 'name' => 'bob', 'product_id' => 3, 'product' => 'keyboard', 'price' => 25, ) ); $output = array(); $userColumnIntersect = array_flip(array( 'id', 'name', )); $productColumnIntersect = array_flip(array( 'product', 'price', )); foreach($data as $row){ $id = $row['id']; if(!isset($output[$id])){ $output[$id] = array_intersect_key($row, $internalOrderColumnIntersect); $output[$id]['products'] = array(); } $productId = $row['product_id']; if(!isset($output[$id]['products'][$productId])){ $productDataRow = array_intersect_key($row, $productColumnIntersect); $output[$id]['products'][$productId] = $productDataRow; } } echo '<pre>'; print_r($output);

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.0180.00418.43
8.3.60.0000.01416.75
8.3.50.0110.00817.32
8.3.40.0110.00418.75
8.3.30.0140.00318.66
8.3.20.0030.00618.80
8.3.10.0050.00520.56
8.3.00.0000.00819.38
8.2.180.0160.00017.00
8.2.170.0110.00422.96
8.2.160.0130.00318.86
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0080.00418.93
8.2.110.0090.00321.02
8.2.100.0030.00917.97
8.2.90.0070.00319.47
8.2.80.0040.00419.40
8.2.70.0040.00417.63
8.2.60.0040.00417.93
8.2.50.0030.00618.07
8.2.40.0070.00018.21
8.2.30.0030.00618.18
8.2.20.0000.00917.75
8.2.10.0070.00017.69
8.2.00.0030.00617.69
8.1.280.0100.00725.92
8.1.270.0000.00723.99
8.1.260.0090.00026.35
8.1.250.0050.00228.09
8.1.240.0110.00022.48
8.1.230.0060.00620.89
8.1.220.0040.00417.74
8.1.210.0050.00318.92
8.1.200.0000.01017.35
8.1.190.0000.00717.40
8.1.180.0030.00518.10
8.1.170.0000.00818.70
8.1.160.0000.00818.89
8.1.150.0020.00518.66
8.1.140.0000.00717.38
8.1.130.0040.00417.71
8.1.120.0000.00717.39
8.1.110.0030.00617.40
8.1.100.0050.00217.41
8.1.90.0050.00217.44
8.1.80.0030.00317.39
8.1.70.0030.00317.47
8.1.60.0080.00017.56
8.1.50.0000.00717.51
8.1.40.0000.00717.55
8.1.30.0000.00817.63
8.1.20.0030.00517.70
8.1.10.0040.00417.50
8.1.00.0030.00617.48
8.0.300.0040.00419.98
8.0.290.0040.00416.75
8.0.280.0070.00018.32
8.0.270.0070.00017.18
8.0.260.0000.00716.80
8.0.250.0000.00716.87
8.0.240.0030.00517.05
8.0.230.0080.00017.01
8.0.220.0050.00216.89
8.0.210.0040.00416.96
8.0.200.0030.00317.00
8.0.190.0000.00716.98
8.0.180.0070.00017.00
8.0.170.0090.00016.85
8.0.160.0050.00217.01
8.0.150.0030.00516.93
8.0.140.0020.00516.92
8.0.130.0030.00313.38
8.0.120.0020.00516.92
8.0.110.0040.00416.83
8.0.100.0000.00816.98
8.0.90.0000.00916.88
8.0.80.0090.01317.01
8.0.70.0040.00416.96
8.0.60.0040.00416.93
8.0.50.0070.00016.94
8.0.30.0120.00617.13
8.0.20.0030.01516.93
8.0.10.0030.00617.07
8.0.00.0130.01016.72
7.4.330.0000.00512.97
7.4.320.0000.00716.53
7.4.300.0000.00616.60
7.4.290.0030.00316.54
7.4.280.0030.00616.50
7.4.270.0000.00716.54
7.4.260.0030.00313.23
7.4.250.0000.00816.45
7.4.240.0030.00316.64
7.4.230.0070.00016.53
7.4.220.0110.00716.36
7.4.210.0070.01316.47
7.4.200.0030.00316.63
7.4.190.0000.00716.57
7.4.160.0130.00316.64
7.4.150.0110.00716.59
7.4.140.0070.01116.56
7.4.130.0070.01716.65
7.4.120.0150.00316.70
7.4.110.0130.00316.50
7.4.100.0070.01016.74
7.4.90.0110.00716.61
7.4.80.0100.01219.39
7.4.70.0150.01216.52
7.4.60.0090.01216.51
7.4.50.0000.00516.56
7.4.40.0000.01416.64
7.4.30.0090.00616.42
7.4.00.0100.00614.91
7.3.330.0060.00013.09
7.3.320.0040.00413.07
7.3.310.0040.00416.23
7.3.300.0070.00016.37
7.3.290.0070.00916.40
7.3.280.0010.01316.33
7.3.270.0120.00716.44
7.3.260.0100.01016.34
7.3.250.0130.00616.52
7.3.240.0100.00616.65
7.3.230.0040.01316.43
7.3.210.0130.00716.34
7.3.200.0060.01616.35
7.3.190.0150.00616.44
7.3.180.0060.01016.63
7.3.170.0090.00916.44
7.3.160.0120.00916.48
7.3.120.0100.00714.81
7.3.10.0040.01116.57
7.3.00.0070.00316.77
7.2.330.0180.00016.66
7.2.320.0230.00016.56
7.2.310.0070.01016.66
7.2.300.0120.01116.76
7.2.290.0030.01416.75
7.2.130.0040.00817.01
7.2.120.0090.00316.93
7.2.110.0070.00717.09
7.2.100.0090.00616.93
7.2.90.0060.00616.87
7.2.80.0030.01316.94
7.2.70.0110.00417.13
7.2.60.0060.01016.94
7.2.50.0070.00316.89
7.2.40.0000.00916.97
7.2.30.0060.00917.02
7.2.20.0000.01217.08
7.2.10.0080.00416.80
7.2.00.0070.00918.20
7.1.250.0060.00615.82
7.1.200.0040.00815.65
7.1.100.0030.01018.15
7.1.70.0040.00417.17
7.1.60.0130.01019.31
7.1.50.0000.01316.60
7.1.00.0030.03322.43
7.0.200.0110.00016.89
7.0.140.0030.07021.92
7.0.120.0070.06322.13
7.0.60.0030.04319.98
7.0.50.0100.07017.88
7.0.40.0000.09020.27
7.0.30.0200.05020.07
7.0.20.0300.07020.26
7.0.10.0330.04720.05
7.0.00.0100.08320.33
5.6.280.0030.07721.02
5.6.210.0000.06320.73
5.6.200.0070.05018.29
5.6.190.0070.08320.39
5.6.180.0230.06020.52
5.6.170.0370.07720.55
5.6.160.0200.07020.55
5.6.150.0030.07018.12
5.6.140.0100.08018.18
5.6.130.0030.05018.28
5.6.120.0100.08021.00
5.6.110.0030.04720.98
5.6.100.0030.05021.11
5.6.90.0100.06321.00
5.6.80.0030.08720.49
5.6.70.0370.06320.51
5.5.350.0370.07320.39
5.5.340.0070.07717.97
5.5.330.0030.09020.42
5.5.320.0370.06020.30
5.5.310.0370.07020.55
5.5.300.0070.04317.95
5.5.290.0030.08318.08
5.5.280.0030.04020.85
5.5.270.0030.06720.77
5.5.260.0100.08320.80
5.5.250.0100.08320.67
5.5.240.0070.06720.24
5.4.450.0130.07719.43
5.4.440.0070.06719.48
5.4.430.0070.04719.56
5.4.420.0070.05319.31
5.4.410.0100.04019.35
5.4.400.0070.03718.98
5.4.390.0030.04018.87
5.4.380.0100.03719.16
5.4.370.0030.07719.20
5.4.360.0070.04318.87
5.4.350.0070.07019.02
5.4.340.0130.05019.08
5.4.320.0130.06019.14
5.4.310.0100.06719.00
5.4.300.0100.03719.14
5.4.290.0070.03719.02
5.4.280.0000.04319.07
5.4.270.0000.06719.24
5.4.260.0030.04019.24
5.4.250.0070.06019.14
5.4.240.0070.03719.14
5.4.230.0030.03718.87
5.4.220.0100.07319.19
5.4.210.0030.06719.14
5.4.200.0030.04318.85
5.4.190.0070.05719.14
5.4.180.0070.04319.15
5.4.170.0070.07319.14
5.4.160.0130.07318.83
5.4.150.0170.07019.12
5.4.140.0000.08716.23
5.4.130.0070.06316.33
5.4.120.0030.06716.38
5.4.110.0070.06716.30
5.4.100.0070.03716.46
5.4.90.0070.07016.72
5.4.80.0070.05016.37
5.4.70.0100.03016.39
5.4.60.0030.07716.36
5.4.50.0070.04716.45
5.4.40.0000.05316.36
5.4.30.0130.05016.31
5.4.20.0070.04016.64
5.4.10.0030.06316.38
5.4.00.0070.06015.86
5.3.290.0070.07714.67
5.3.280.0070.07314.59
5.3.270.0130.07014.62
5.3.260.0000.07314.55
5.3.250.0100.07714.65
5.3.240.0070.06714.68
5.3.230.0030.07714.63
5.3.220.0100.06714.57
5.3.210.0100.05714.71
5.3.200.0030.06314.64
5.3.190.0070.07314.63
5.3.180.0070.07314.61
5.3.170.0000.04714.57
5.3.160.0030.08014.62
5.3.150.0070.05714.61
5.3.140.0000.05314.71
5.3.130.0070.07714.44
5.3.120.0130.06014.55
5.3.110.0130.06314.47
5.3.100.0030.05314.07
5.3.90.0030.04714.05
5.3.80.0130.06713.91
5.3.70.0030.04013.94
5.3.60.0100.03014.16
5.3.50.0070.06713.95
5.3.40.0100.03313.97
5.3.30.0170.03713.96
5.3.20.0070.04013.74
5.3.10.0070.07013.55
5.3.00.0000.04013.57
5.2.170.0070.02711.16
5.2.160.0070.06311.30
5.2.150.0000.03311.17
5.2.140.0100.02711.15
5.2.130.0070.04711.11
5.2.120.0070.02711.26
5.2.110.0030.04711.18
5.2.100.0030.03311.16
5.2.90.0030.03311.08
5.2.80.0030.06711.06
5.2.70.0000.06311.25
5.2.60.0170.03011.11
5.2.50.0070.05311.02
5.2.40.0030.05310.96
5.2.30.0130.02311.04
5.2.20.0030.03010.88
5.2.10.0070.05710.88
5.2.00.0000.06710.80
5.1.60.0000.0379.98
5.1.50.0000.0409.97
5.1.40.0100.03010.05
5.1.30.0030.03710.38
5.1.20.0030.02310.50
5.1.10.0030.05710.21
5.1.00.0000.07010.21
5.0.50.0030.0308.71
5.0.40.0030.0438.48
5.0.30.0070.0338.37
5.0.20.0000.0238.37
5.0.10.0000.0338.37
5.0.00.0000.0378.37
4.4.90.0000.0378.37
4.4.80.0070.0338.37
4.4.70.0000.0178.37
4.4.60.0000.0178.37
4.4.50.0030.0378.37
4.4.40.0070.0338.37
4.4.30.0000.0178.37
4.4.20.0000.0208.37
4.4.10.0030.0238.37
4.4.00.0030.0238.37
4.3.110.0030.0238.37
4.3.100.0030.0178.37
4.3.90.0000.0178.37
4.3.80.0000.0278.37
4.3.70.0000.0178.37
4.3.60.0030.0378.37
4.3.50.0030.0178.37
4.3.40.0000.0278.37
4.3.30.0000.0338.37
4.3.20.0030.0378.37
4.3.10.0000.0338.37
4.3.00.0070.0138.37

preferences:
52.26 ms | 401 KiB | 5 Q