3v4l.org

run code in 300+ PHP versions simultaneously
<?php $items = array( (object) array('id' => 1, 'parent_id' => 0), (object) array('id' => 2, 'parent_id' => 1), (object) array('id' => 3, 'parent_id' => 1), (object) array('id' => 4, 'parent_id' => 2), (object) array('id' => 5, 'parent_id' => 4), (object) array('id' => 6, 'parent_id' => 0), ); function buildTree($items) { $childs = array(); foreach($items as $item) $childs[$item->parent_id][] = $item; foreach($items as $item) if (isset($childs[$item->id])) $item->childs = $childs[$item->id]; return $childs[0]; } $tree = buildTree($items); print_r($tree);

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.60.0070.00716.38
8.3.50.0320.00922.12
8.3.40.0000.01518.73
8.3.30.0070.00719.12
8.3.20.0000.00820.35
8.3.10.0040.00421.91
8.3.00.0000.00819.38
8.2.180.0220.00016.75
8.2.170.0180.00018.91
8.2.160.0110.00322.96
8.2.150.0050.00325.66
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0080.00019.48
8.2.110.0040.00422.24
8.2.100.0000.01219.17
8.2.90.0000.00817.75
8.2.80.0080.00018.90
8.2.70.0040.00417.93
8.2.60.0040.00418.03
8.2.50.0070.00018.10
8.2.40.0090.00019.56
8.2.30.0040.00419.45
8.2.20.0050.00317.72
8.2.10.0080.00018.19
8.2.00.0040.00418.03
8.1.280.0090.00625.92
8.1.270.0160.00020.38
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0000.00922.67
8.1.230.0030.01019.10
8.1.220.0040.00417.79
8.1.210.0030.00518.77
8.1.200.0080.00017.35
8.1.190.0030.00517.35
8.1.180.0090.00018.10
8.1.170.0000.00818.46
8.1.160.0000.00718.86
8.1.150.0040.00418.90
8.1.140.0000.00717.51
8.1.130.0030.00317.71
8.1.120.0040.00417.50
8.1.110.0030.00417.41
8.1.100.0000.00717.38
8.1.90.0100.00017.46
8.1.80.0040.00417.45
8.1.70.0040.00417.37
8.1.60.0000.01017.50
8.1.50.0000.00817.34
8.1.40.0060.00317.47
8.1.30.0000.00817.69
8.1.20.0030.00617.63
8.1.10.0000.00817.63
8.1.00.0080.00017.46
8.0.300.0040.00419.78
8.0.290.0040.00416.75
8.0.280.0000.00718.50
8.0.270.0000.00717.33
8.0.260.0040.00417.33
8.0.250.0030.00317.04
8.0.240.0030.00317.04
8.0.230.0070.00017.00
8.0.220.0000.00716.86
8.0.210.0050.00316.86
8.0.200.0030.00317.06
8.0.190.0050.00316.96
8.0.180.0000.00817.01
8.0.170.0080.00016.87
8.0.160.0000.00816.86
8.0.150.0000.00816.79
8.0.140.0060.00316.80
8.0.130.0030.00313.36
8.0.120.0000.00716.93
8.0.110.0000.00716.93
8.0.100.0040.00416.85
8.0.90.0040.00416.94
8.0.80.0150.00416.98
8.0.70.0050.00216.95
8.0.60.0050.00317.08
8.0.50.0040.00416.85
8.0.30.0070.00817.03
8.0.20.0120.00817.40
8.0.10.0050.00217.14
8.0.00.0070.01016.72
7.4.330.0030.00315.14
7.4.320.0060.00016.37
7.4.300.0030.00316.49
7.4.290.0040.00816.48
7.4.280.0040.00416.50
7.4.270.0030.00316.61
7.4.260.0000.00716.60
7.4.250.0040.00416.57
7.4.240.0020.00616.56
7.4.230.0030.00316.62
7.4.220.0150.00316.68
7.4.210.0030.01216.41
7.4.200.0000.00716.43
7.4.160.0110.00416.68
7.4.150.0060.01217.40
7.4.140.0130.01117.86
7.4.130.0100.00916.54
7.4.120.0120.00816.40
7.4.110.0040.01316.63
7.4.100.0130.01016.48
7.4.90.0100.01016.42
7.4.80.0150.00319.39
7.4.70.0070.01316.40
7.4.60.0080.00816.70
7.4.50.0090.00016.60
7.4.40.0030.01416.68
7.4.30.0060.01216.52
7.4.00.0030.01014.86
7.3.330.0050.00013.42
7.3.320.0000.00513.38
7.3.310.0070.00016.42
7.3.300.0070.00016.42
7.3.290.0050.00916.37
7.3.280.0070.00816.42
7.3.270.0100.00717.40
7.3.260.0100.00716.70
7.3.250.0070.01016.42
7.3.240.0170.00716.67
7.3.230.0120.00616.43
7.3.210.0140.00716.33
7.3.200.0150.00319.39
7.3.190.0080.00816.41
7.3.180.0100.01016.31
7.3.170.0120.00916.56
7.3.160.0030.01216.40
7.2.330.0090.00916.77
7.2.320.0160.00916.78
7.2.310.0140.00516.66
7.2.300.0100.00716.80
7.2.290.0050.01116.86
7.1.70.0100.00016.98
7.1.60.0100.01019.59
7.1.50.0030.02017.02
7.1.00.0000.09322.57
7.0.200.0180.01116.56
7.0.60.0130.07719.84
7.0.50.0130.07717.87
7.0.40.0170.07720.18
7.0.30.0230.04320.22
7.0.20.0230.04720.30
7.0.10.0170.07720.07
7.0.00.0200.04020.32
5.6.280.0070.06721.09
5.6.210.0070.04320.67
5.6.200.0100.07318.27
5.6.190.0230.07720.57
5.6.180.0270.04720.48
5.6.170.0270.06320.48
5.6.160.0170.06020.55
5.6.150.0200.07018.17
5.6.140.0070.08318.14
5.6.130.0130.07018.28
5.6.120.0030.04721.02
5.6.110.0100.08721.12
5.6.100.0100.06020.99
5.6.90.0100.07321.11
5.6.80.0130.07320.51
5.5.350.0270.06020.49
5.5.340.0130.04718.09
5.5.330.0170.06720.40
5.5.320.0100.04320.30
5.5.310.0130.08320.34
5.5.300.0200.07317.98
5.5.290.0100.04317.95
5.5.280.0000.04320.88
5.5.270.0070.08720.66
5.5.260.0000.05020.73
5.5.250.0070.03720.67
5.5.240.0130.08020.04
5.4.450.0130.04319.20
5.4.440.0200.03719.41
5.4.430.0230.04719.19
5.4.420.0330.03719.32
5.4.410.0230.05319.34
5.4.400.0130.04318.99
5.4.390.0270.06718.98
5.4.380.0200.06319.09
5.4.370.0170.04019.06
5.4.360.0270.04719.31
5.4.350.0200.04719.00
5.4.340.0130.04719.06
5.4.320.0200.05019.09
5.4.310.0270.06018.98
5.4.300.0200.05719.20
5.4.290.0100.05719.22
5.4.280.0230.07019.22
5.4.270.0170.08018.98
5.4.260.0200.06318.87
5.4.250.0270.03318.86
5.4.240.0130.05019.30
5.4.230.0270.06719.21
5.4.220.0230.07019.23
5.4.210.0200.06319.21
5.4.200.0200.05019.23
5.4.190.0200.06019.08
5.4.180.0200.03319.21
5.4.170.0270.08019.05
5.4.160.0200.04018.86
5.4.150.0100.04719.07
5.4.140.0200.05016.38
5.4.130.0200.06316.45
5.4.120.0230.02716.45
5.4.110.0130.04016.45
5.4.100.0200.05016.20
5.4.90.0300.07016.36
5.4.80.0270.05316.22
5.4.70.0130.04316.36
5.4.60.0200.06716.54
5.4.50.0200.04316.43
5.4.40.0200.04316.43
5.4.30.0200.06316.50
5.4.20.0230.03016.19
5.4.10.0230.06716.53
5.4.00.0200.05315.78
5.3.290.0170.05014.57
5.3.280.0170.06314.52
5.3.270.0170.06714.60
5.3.260.0230.07014.63
5.3.250.0200.03714.59
5.3.240.0100.04314.58
5.3.230.0070.04014.57
5.3.220.0070.07314.79
5.3.210.1200.02714.48
5.3.200.1430.04014.64
5.3.190.1800.04714.63
5.3.180.1800.04714.57
5.3.170.1830.05014.54
5.3.160.1700.04014.64
5.3.150.1900.03314.57
5.3.140.1700.04314.54
5.3.130.1870.04314.66
5.3.120.1730.04714.52
5.3.110.1470.04314.59
5.3.100.1930.03714.11
5.3.90.1930.05714.01
5.3.80.1930.03713.94
5.3.70.1700.04714.00
5.3.60.1170.04013.98
5.3.50.1730.04313.96
5.3.40.1870.04313.87
5.3.30.1800.04313.82
5.3.20.1770.04013.81
5.3.10.1830.04013.88
5.3.00.1930.04713.72
5.2.170.1270.03311.17
5.2.160.0770.03311.16
5.2.150.0000.03311.05
5.2.140.0000.03311.29
5.2.130.0330.03011.02
5.2.120.1170.03711.09
5.2.110.1430.03711.07
5.2.100.1230.03011.25
5.2.90.1270.03011.22
5.2.80.1170.03011.18
5.2.70.1300.02711.18
5.2.60.1330.02711.28
5.2.50.1370.03710.95
5.2.40.1070.02310.91
5.2.30.0900.03011.00
5.2.20.1170.02310.87
5.2.10.1170.02010.78
5.2.00.1230.03310.86
5.1.60.1370.03010.01
5.1.50.1070.02710.00
5.1.40.0030.0239.96
5.1.30.0030.02310.41
5.1.20.0030.02310.27
5.1.10.0000.02710.30
5.1.00.0730.03310.13
5.0.50.0570.0138.78
5.0.40.0430.0208.39
5.0.30.0530.0338.21
5.0.20.0530.0208.14
5.0.10.0400.0208.33
5.0.00.0530.0308.25
4.4.90.0470.0177.55
4.4.80.0570.0107.55
4.4.70.0270.0177.55
4.4.60.0530.0137.55
4.4.50.0500.0177.55
4.4.40.0470.0277.55
4.4.30.0500.0177.55
4.4.20.0470.0177.55
4.4.10.0470.0177.55
4.4.00.0530.0237.55
4.3.110.0600.0107.55
4.3.100.0430.0137.55
4.3.90.0570.0137.55
4.3.80.0500.0277.55
4.3.70.0530.0177.55
4.3.60.0570.0107.55
4.3.50.0530.0177.55
4.3.40.0570.0237.55
4.3.30.0300.0137.55
4.3.20.0300.0137.55
4.3.10.0270.0137.55
4.3.00.0230.0177.55

preferences:
35.46 ms | 401 KiB | 5 Q