3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getTree($treeByParent, $treeByCat, $id, $listed = []) { $gTree = []; $gTree[] = $treeByCat[ $id ]; if ( count($treeByParent[ $id ]) > 0) { foreach ($treeByParent[ $id ] as $cat) $gTree[] = $cat; } if ( count($treeByParent[$id]) > 0 ) getTree($treeByParent, $treeByCat, $treeByCat[ $id ]); return $gTree; } $treeByParent = array( 0 => array(1, 2), 1 => array(3, 7), 3 => array(4), 4 => array(5) ); $treeByCat = array( 1 => 0, 2 => 0, 3 => 1, 7 => 1, 4 => 3, 5 => 4 ); print_r( getTree($treeByParent, $treeByCat, 3) );

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.0040.01116.63
8.3.50.0070.01222.11
8.3.40.0150.00018.58
8.3.30.0070.00719.04
8.3.20.0070.00020.18
8.3.10.0040.00423.53
8.3.00.0040.00419.51
8.2.180.0070.00718.15
8.2.170.0150.00622.96
8.2.160.0100.00320.35
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0140.00426.16
8.2.120.0040.00419.79
8.2.110.0000.00922.30
8.2.100.0110.00018.03
8.2.90.0030.00619.30
8.2.80.0000.00818.16
8.2.70.0050.00317.63
8.2.60.0000.00917.93
8.2.50.0000.00818.07
8.2.40.0040.00418.22
8.2.30.0050.00218.08
8.2.20.0040.00417.83
8.2.10.0070.00018.20
8.2.00.0030.00617.82
8.1.280.0120.00625.92
8.1.270.0050.00322.25
8.1.260.0000.00826.35
8.1.250.0070.00028.09
8.1.240.0000.00923.76
8.1.230.0070.00718.96
8.1.220.0040.00417.74
8.1.210.0000.00918.77
8.1.200.0030.00617.13
8.1.190.0040.00417.52
8.1.180.0090.00018.10
8.1.170.0000.00918.59
8.1.160.0070.00022.02
8.1.150.0030.00618.70
8.1.140.0000.00817.51
8.1.130.0030.00517.83
8.1.120.0020.00517.55
8.1.110.0080.00017.36
8.1.100.0040.00417.53
8.1.90.0070.00017.43
8.1.80.0000.00717.34
8.1.70.0070.00017.43
8.1.60.0090.00017.59
8.1.50.0040.00417.53
8.1.40.0040.00417.43
8.1.30.0000.00817.61
8.1.20.0040.00417.60
8.1.10.0070.00017.59
8.1.00.0050.00317.54
8.0.300.0070.00018.77
8.0.290.0030.00317.04
8.0.280.0040.00418.33
8.0.270.0040.00417.18
8.0.260.0040.00417.26
8.0.250.0030.00316.91
8.0.240.0050.00216.93
8.0.230.0080.00016.94
8.0.220.0050.00216.96
8.0.210.0070.00016.96
8.0.200.0070.00016.95
8.0.190.0000.00716.94
8.0.180.0070.00016.83
8.0.170.0040.00416.90
8.0.160.0070.00017.01
8.0.150.0070.00017.02
8.0.140.0000.00716.93
8.0.130.0030.00313.40
8.0.120.0050.00217.00
8.0.110.0000.00716.88
8.0.100.0000.00716.83
8.0.90.0070.00017.00
8.0.80.0080.01216.95
8.0.70.0000.00716.98
8.0.60.0040.00416.96
8.0.50.0040.00416.84
8.0.30.0110.00917.11
8.0.20.0120.00617.40
8.0.10.0030.00517.16
8.0.00.0090.00916.87
7.4.330.0000.00515.00
7.4.320.0000.00716.61
7.4.300.0030.00316.65
7.4.290.0030.00316.63
7.4.280.0000.00716.65
7.4.270.0020.00516.49
7.4.260.0020.00516.59
7.4.250.0080.00016.38
7.4.240.0020.00516.54
7.4.230.0000.00716.42
7.4.220.0030.01416.72
7.4.210.0100.00816.59
7.4.200.0040.00316.59
7.4.190.0030.00316.47
7.4.160.0040.01516.48
7.4.150.0100.00617.40
7.4.140.0100.00917.86
7.4.130.0060.01116.62
7.4.120.0130.00616.51
7.4.110.0070.01016.44
7.4.100.0100.01016.55
7.4.90.0090.00916.72
7.4.80.0060.01519.39
7.4.70.0030.01416.50
7.4.60.0120.00916.48
7.4.50.0040.00416.33
7.4.40.0030.01422.77
7.4.30.0090.00716.72
7.4.00.0040.01114.88
7.3.330.0000.00613.42
7.3.320.0030.00313.43
7.3.310.0000.00716.53
7.3.300.0000.00716.31
7.3.290.0090.00616.45
7.3.280.0150.00416.44
7.3.270.0060.01117.40
7.3.260.0220.00016.53
7.3.250.0050.01116.40
7.3.240.0130.00716.39
7.3.230.0120.00416.63
7.3.210.0070.01016.51
7.3.200.0000.01919.39
7.3.190.0090.00916.59
7.3.180.0080.00816.59
7.3.170.0060.00916.41
7.3.160.0080.00816.45
7.3.120.0000.01414.76
7.2.330.0060.01616.76
7.2.320.0070.01116.57
7.2.310.0130.00316.84
7.2.300.0080.00816.51
7.2.290.0080.00816.61
7.2.60.0040.00717.05
7.1.200.0100.00315.59
7.1.100.0080.00417.96
7.1.70.0000.01617.20
7.1.60.0070.01719.33
7.1.50.0070.01416.92
7.1.00.0030.07022.36
7.0.200.0030.00614.73
7.0.140.0030.07722.02
7.0.60.0070.07719.95
7.0.50.0030.08317.88
7.0.40.0100.08720.30
7.0.30.0130.08020.25
7.0.20.0400.06720.21
7.0.10.0130.08320.25
7.0.00.0100.07320.29
5.6.280.0130.06321.11
5.6.210.0100.07320.61
5.6.200.0100.08018.15
5.6.190.0070.04020.77
5.6.180.0230.04320.48
5.6.170.0230.06720.47
5.6.160.0070.08320.48
5.6.150.0130.04718.28
5.6.140.0100.07018.23
5.6.130.0030.09018.28
5.6.120.0130.08021.18
5.6.110.0070.08021.09
5.6.100.0170.07721.14
5.6.90.0170.03721.03
5.6.80.0170.06020.38
5.6.70.4470.03320.41
5.5.350.0170.07720.53
5.5.340.0070.08317.95
5.5.330.0030.06720.19
5.5.320.0070.03720.27
5.5.310.0370.07320.21
5.5.300.0030.05018.08
5.5.290.0030.08317.98
5.5.280.0100.04320.75
5.5.270.0170.06020.79
5.5.260.0070.04720.79
5.5.250.0170.08020.58
5.5.240.0200.07320.29
5.4.450.0130.05719.17
5.4.440.0100.06319.18
5.4.430.0200.04319.58
5.4.420.0170.05019.47
5.4.410.0070.05719.21
5.4.400.0100.05018.84
5.4.390.0030.06018.88
5.4.380.0230.05018.81
5.4.370.0230.07718.59
5.4.360.0270.07018.79
5.4.350.0400.06018.70
5.4.340.0200.05318.80
5.4.320.0070.03812.51
5.4.310.0060.04012.50
5.4.300.0070.03812.50
5.4.290.0040.04112.50
5.4.280.0030.03812.37
5.4.270.0050.03712.38
5.4.260.0060.03812.38
5.4.250.0070.03612.37
5.4.240.0090.03212.38
5.4.230.0100.03512.36
5.4.220.0060.03612.37
5.4.210.0030.03812.37
5.4.200.0070.03812.37
5.4.190.0090.03312.37
5.4.180.0060.03612.36
5.4.170.0080.03712.37
5.4.160.0030.04212.36
5.4.150.0040.04012.36
5.4.140.0050.04412.05
5.4.130.0090.03312.04
5.4.120.0130.04811.99
5.4.110.0090.03911.98
5.4.100.0090.03211.99
5.4.90.0080.03411.99
5.4.80.0050.03911.99
5.4.70.0060.03811.99
5.4.60.0070.04811.98
5.4.50.0100.05111.98
5.4.40.0080.06111.97
5.4.30.0120.05011.97
5.4.20.0140.05911.97
5.4.10.0140.05611.97
5.4.00.0120.05611.45
5.3.290.0030.04712.80
5.3.280.0100.06012.71
5.3.270.0090.06112.73
5.3.260.0140.05412.72
5.3.250.0110.05812.72
5.3.240.0120.05412.72
5.3.230.0080.06412.71
5.3.220.0100.05612.68
5.3.210.0130.05712.68
5.3.200.0110.05512.68
5.3.190.0120.05612.68
5.3.180.0080.05712.67
5.3.170.0060.05712.67
5.3.160.0130.05512.67
5.3.150.0130.05412.67
5.3.140.0150.04712.66
5.3.130.0080.05712.66
5.3.120.0080.05612.65
5.3.110.0070.03812.66
5.3.100.0080.04812.12
5.3.90.0100.04412.08
5.3.80.0090.06212.07
5.3.70.0140.05012.07
5.3.60.0140.04412.07
5.3.50.0110.03512.00
5.3.40.0100.03912.00
5.3.30.0060.04111.95
5.3.20.0070.04411.74
5.3.10.0050.03611.70
5.3.00.0100.05011.69
5.2.170.0100.0479.18
5.2.160.0050.0439.18
5.2.150.0060.0309.18
5.2.140.0040.0339.18
5.2.130.0070.0299.14
5.2.120.0070.0299.14
5.2.110.0050.0319.14
5.2.100.0060.0299.14
5.2.90.0030.0319.14
5.2.80.0040.0329.14
5.2.70.0050.0319.14
5.2.60.0050.0319.09
5.2.50.0020.0479.06
5.2.40.0040.0429.03
5.2.30.0030.0459.02
5.2.20.0050.0299.00
5.2.10.0030.0308.92
5.2.00.0050.0398.78
5.1.60.0060.0318.05
5.1.50.0050.0338.06
5.1.40.0040.0338.04
5.1.30.0050.0368.40
5.1.20.0070.0358.41
5.1.10.0040.0448.14
5.1.00.0050.0378.14
5.0.50.0050.0316.61
5.0.40.0050.0326.48
5.0.30.0110.0496.28
5.0.20.0030.0336.26
5.0.10.0040.0256.24
5.0.00.0070.0366.23
4.4.90.0040.0154.78
4.4.80.0030.0164.75
4.4.70.0030.0164.76
4.4.60.0020.0234.76
4.4.50.0050.0144.77
4.4.40.0050.0254.71
4.4.30.0030.0164.76
4.4.20.0000.0194.84
4.4.10.0010.0184.84
4.4.00.0040.0364.76
4.3.110.0030.0234.67
4.3.100.0030.0254.66
4.3.90.0070.0334.64
4.3.80.0040.0354.58
4.3.70.0030.0234.63
4.3.60.0050.0244.63
4.3.50.0020.0254.63
4.3.40.0040.0334.54
4.3.30.0040.0203.28
4.3.20.0020.0173.26
4.3.10.0020.0223.23
4.3.00.0000.0236.92

preferences:
39.17 ms | 401 KiB | 5 Q