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' => 0), (object) array('id' => 3, 'parent_id' => 0), (object) array('id' => 4, 'parent_id' => 1), (object) array('id' => 5, 'parent_id' => 1), (object) array('id' => 6, 'parent_id' => 2), ); 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.0150.00016.75
8.3.50.0070.01522.05
8.3.40.0000.01419.02
8.3.30.0120.00422.96
8.3.20.0070.00722.96
8.2.180.0150.00616.88
8.2.170.0110.00322.96
8.2.160.0040.01120.27
8.2.150.0040.01119.18
8.1.280.0070.00725.92
7.4.10.0100.01215.93
7.4.00.0120.00715.39
7.3.130.0160.00315.69
7.3.120.0100.01315.50
7.3.110.0120.01115.61
7.3.100.0130.00915.58
7.3.90.0120.00715.74
7.3.80.0090.01115.65
7.3.70.0110.00715.62
7.3.60.0090.01215.61
7.3.50.0160.00715.44
7.3.40.0150.00515.68
7.3.30.0130.00515.48
7.3.20.0090.01417.34
7.3.10.0120.01017.54
7.3.00.0110.01117.26
7.2.260.0130.01015.92
7.2.250.0140.00815.94
7.2.240.0080.01315.83
7.2.230.0070.01216.03
7.2.220.0060.01815.88
7.2.210.0120.01115.73
7.2.200.0100.00915.84
7.2.190.0150.00815.76
7.2.180.0120.00915.91
7.2.170.0140.00615.82
7.2.160.0110.00915.91
7.2.150.0020.02017.76
7.2.140.0110.01117.70
7.2.130.0110.00817.81
7.2.120.0160.00817.76
7.2.110.0080.01217.74
7.2.100.0080.01317.64
7.2.90.0150.01017.66
7.2.80.0150.00617.63
7.2.70.0160.00517.73
7.2.60.0100.01217.75
7.2.50.0170.00917.79
7.2.40.0130.01017.79
7.2.30.0170.00717.67
7.2.20.0150.00917.59
7.2.10.0110.01317.53
7.2.00.0090.01118.29
7.1.330.0050.01416.58
7.1.320.0080.01216.69
7.1.310.0110.00716.72
7.1.300.0080.01416.60
7.1.290.0100.01016.67
7.1.280.0200.00716.58
7.1.270.0120.00816.40
7.1.260.0100.00916.49
7.1.250.0140.00616.53
7.1.240.0110.00816.57
7.1.230.0140.00716.58
7.1.220.0110.01016.58
7.1.210.0100.00816.44
7.1.200.0130.00516.56
7.1.190.0160.00716.57
7.1.180.0110.00614.62
7.1.170.0140.01216.41
7.1.160.0130.00916.59
7.1.150.0140.00616.48
7.1.140.0080.01316.56
7.1.130.0170.00716.63
7.1.120.0100.00916.60
7.1.110.0100.01216.54
7.1.100.0050.01016.99
7.1.90.0120.00916.58
7.1.80.0140.00516.54
7.1.70.0110.00516.90
7.1.60.0140.01017.65
7.1.50.0140.01116.63
7.1.40.0100.01016.59
7.1.30.0140.00916.50
7.1.20.0120.00916.38
7.1.10.0100.01016.35
7.1.00.0120.02818.54
7.0.330.0130.00716.30
7.0.320.0120.00916.07
7.0.310.0170.00716.16
7.0.300.0180.00616.07
7.0.290.0160.00716.07
7.0.280.1480.01216.12
7.0.270.0080.01216.06
7.0.260.0110.01016.28
7.0.250.0110.01116.26
7.0.240.0680.01116.39
7.0.230.0060.01416.32
7.0.220.0070.01616.17
7.0.210.0150.00416.11
7.0.200.0100.01116.36
7.0.190.0120.00716.29
7.0.180.0080.01216.26
7.0.170.0110.00716.21
7.0.160.0140.00716.32
7.0.150.0280.01316.04
7.0.140.0070.01116.17
7.0.130.0150.00816.33
7.0.120.0140.00714.41
7.0.110.0090.01416.20
7.0.100.0140.00514.55
7.0.90.0140.00816.22
7.0.80.0080.01216.23
7.0.70.0160.00716.24
7.0.60.0130.02517.45
7.0.50.0100.03116.88
7.0.40.0140.03116.21
7.0.30.0180.03316.20
7.0.20.0180.03216.19
7.0.10.0100.03416.31
7.0.00.0080.02416.25
5.6.400.0060.01215.23
5.6.390.0120.01015.32
5.6.380.0130.01015.25
5.6.370.0130.00815.19
5.6.360.0100.01215.28
5.6.350.0140.00515.15
5.6.340.0200.00615.37
5.6.330.0080.00613.94
5.6.320.0050.01615.19
5.6.310.0170.00815.40
5.6.300.0110.01415.39
5.6.290.0140.01115.28
5.6.280.0130.02817.05
5.6.270.0120.01115.30
5.6.260.0120.01415.35
5.6.250.0110.01315.24
5.6.240.0080.00815.17
5.6.230.0140.00815.22
5.6.220.0160.00715.24
5.6.210.0090.03417.04
5.6.200.0130.02316.16
5.6.190.0100.02316.97
5.6.180.0210.02817.05
5.6.170.0150.02616.96
5.6.160.0110.03416.93
5.6.150.0120.01716.37
5.6.140.0130.02416.20
5.6.130.0130.03216.22
5.6.120.0080.03117.20
5.6.110.0110.03017.14
5.6.100.0130.03117.18
5.6.90.0040.03217.10
5.6.80.0110.02416.86
5.6.70.0090.00915.21
5.6.60.0150.01015.10
5.6.50.0110.01215.31
5.6.40.0070.01415.26
5.6.30.0150.00815.20
5.6.20.0100.01215.36
5.6.10.0100.01015.17
5.6.00.0100.01115.27
5.5.380.0130.00715.18
5.5.370.0100.01015.13
5.5.360.0130.00815.04
5.5.350.0170.02816.86
5.5.340.0120.02216.09
5.5.330.0140.01817.01
5.5.320.0100.02816.94
5.5.310.0170.03017.01
5.5.300.0140.02516.13
5.5.290.0120.03216.21
5.5.280.0080.02817.00
5.5.270.0070.02017.09
5.5.260.0130.03116.98
5.5.250.0130.01716.95
5.5.240.0090.03216.80
5.5.230.0130.01015.26
5.5.220.0130.00815.34
5.5.210.0130.00515.05
5.5.200.0090.01515.10
5.5.190.0150.00715.30
5.5.180.0120.01015.25
5.5.170.0090.01415.17
5.5.160.0090.01115.17
5.5.150.0090.00613.98
5.5.140.0100.00815.17
5.5.130.0100.00715.13
5.5.120.0110.01115.28
5.5.110.0140.00515.10
5.5.100.0130.00615.02
5.5.90.0100.00915.20
5.5.80.0100.00715.07
5.5.70.0090.01115.21
5.5.60.0100.01115.10
5.5.50.0130.00914.99
5.5.40.0180.00315.24
5.5.30.0100.01215.14
5.5.20.0050.01715.00
5.5.10.0100.01315.24
5.5.00.0120.00915.02
5.4.450.0180.02414.78
5.4.440.0140.02814.75
5.4.430.0120.02014.70
5.4.420.0180.02314.87
5.4.410.0160.01914.77
5.4.400.0110.03214.55
5.4.390.0150.02714.52
5.4.380.0110.02814.46
5.4.370.0110.02014.71
5.4.360.0120.02914.61
5.4.350.0150.02614.63
5.4.340.0140.01414.73
5.4.330.0040.01312.27
5.4.320.0150.02614.63
5.4.310.0150.01414.53
5.4.300.0150.01814.51
5.4.290.0130.02314.71
5.4.280.0140.01914.60
5.4.270.0170.02314.53
5.4.260.0150.02514.63
5.4.250.0100.02214.61
5.4.240.0150.01614.60
5.4.230.0120.01714.75
5.4.220.0140.03014.53
5.4.210.0150.02614.66
5.4.200.0130.02914.67
5.4.190.0140.01514.59
5.4.180.0120.01814.68
5.4.170.0110.02614.65
5.4.160.0110.03214.51
5.4.150.0150.01914.62
5.4.140.0100.02913.69
5.4.130.0140.01513.79
5.4.120.0100.02813.68
5.4.110.0120.02013.74
5.4.100.0160.01613.81
5.4.90.0100.01813.75
5.4.80.0130.02213.78
5.4.70.0120.02813.72
5.4.60.0130.02613.71
5.4.50.0100.02213.72
5.4.40.0160.02613.74
5.4.30.0120.02813.82
5.4.20.0130.02913.78
5.4.10.0120.01513.66
5.4.00.0110.03313.66
5.3.290.0300.03314.82
5.3.280.0270.04014.60
5.3.270.0300.06014.50
5.3.260.0200.06314.63
5.3.250.0200.05714.55
5.3.240.0230.03714.70
5.3.230.0300.03314.65
5.3.220.0270.07014.49
5.3.210.0230.04714.57
5.3.200.0230.03314.54
5.3.190.0100.04314.48
5.3.180.0200.03314.79
5.3.170.0230.03014.46
5.3.160.0170.03714.71
5.3.150.0200.03714.57
5.3.140.0170.04014.71
5.3.130.0170.03714.70
5.3.120.0230.03014.63
5.3.110.0130.04014.55
5.3.100.0230.03314.02
5.3.90.0130.04014.11
5.3.80.0230.05714.03
5.3.70.0200.05314.16
5.3.60.0230.04014.15
5.3.50.0230.04014.04
5.3.40.0100.04313.96
5.3.30.0230.04314.05
5.3.20.0270.05713.61
5.3.10.0270.02313.73
5.3.00.0230.06713.71
5.2.170.0170.03711.24
5.2.160.0200.03011.21
5.2.150.0200.03311.27
5.2.140.0070.03711.07
5.2.130.0200.06011.11
5.2.120.0230.03311.16
5.2.110.0170.02711.01
5.2.100.0170.02711.22
5.2.90.0100.03311.18
5.2.80.0100.03311.21
5.2.70.0100.03311.19
5.2.60.0270.02710.97
5.2.50.0130.03011.03
5.2.40.0170.02311.22
5.2.30.0200.06010.95
5.2.20.0130.03711.05
5.2.10.0130.05010.87
5.2.00.0130.03710.94
5.1.60.0130.03010.13
5.1.50.0130.0279.89
5.1.40.0200.0239.96
5.1.30.0100.03010.41
5.1.20.0100.04010.44
5.1.10.0170.0209.95
5.1.00.0130.0239.97
5.0.50.0030.0238.68
5.0.40.0070.0208.50
5.0.30.0070.0378.36
5.0.20.0030.0278.18
5.0.10.0030.0278.16
5.0.00.0130.0338.30
4.4.90.0030.0176.71
4.4.80.0030.0176.71
4.4.70.0070.0206.71
4.4.60.0070.0176.71
4.4.50.0070.0206.71
4.4.40.0030.0306.71
4.4.30.0030.0176.71
4.4.20.0130.0236.71
4.4.10.0100.0306.71
4.4.00.0100.0336.71
4.3.110.0100.0236.71
4.3.100.0030.0236.71
4.3.90.0030.0206.71
4.3.80.0070.0236.71
4.3.70.0070.0336.71
4.3.60.0030.0276.71
4.3.50.0100.0136.71
4.3.40.0070.0236.71
4.3.30.0030.0306.71
4.3.20.0070.0336.71
4.3.10.0070.0136.71
4.3.00.0030.0336.71

preferences:
42.56 ms | 401 KiB | 5 Q