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, 4) );

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.0130.00716.75
8.3.50.0120.00722.10
8.3.40.0100.00518.79
8.3.30.0100.00319.22
8.3.20.0000.00720.34
8.3.10.0080.00023.60
8.3.00.0050.00319.30
8.2.180.0140.00018.18
8.2.170.0070.00722.96
8.2.160.0080.00520.57
8.2.150.0090.00024.18
8.2.140.0050.00324.66
8.2.130.0100.01026.16
8.2.120.0050.00222.13
8.2.110.0050.00522.08
8.2.100.0100.00317.84
8.2.90.0000.00819.34
8.2.80.0050.00317.97
8.2.70.0100.00017.75
8.2.60.0040.00417.93
8.2.50.0040.00418.07
8.2.40.0060.00318.00
8.2.30.0040.00418.02
8.2.20.0050.00317.80
8.2.10.0040.00418.19
8.2.00.0080.00317.88
8.1.280.0140.00025.92
8.1.270.0050.00322.04
8.1.260.0080.00026.35
8.1.250.0000.00728.09
8.1.240.0040.00423.77
8.1.230.0000.01119.15
8.1.220.0030.00517.74
8.1.210.0000.00918.77
8.1.200.0030.00617.48
8.1.190.0050.00317.63
8.1.180.0030.00518.10
8.1.170.0060.00318.49
8.1.160.0080.00022.03
8.1.150.0070.00018.68
8.1.140.0000.00717.38
8.1.130.0000.00717.84
8.1.120.0030.00317.45
8.1.110.0040.00417.44
8.1.100.0040.00417.47
8.1.90.0050.00317.48
8.1.80.0000.00717.37
8.1.70.0000.00717.43
8.1.60.0030.00617.61
8.1.50.0000.00817.52
8.1.40.0040.00417.55
8.1.30.0080.00017.64
8.1.20.0070.00017.50
8.1.10.0060.00317.58
8.1.00.0050.00317.56
8.0.300.0040.00418.77
8.0.290.0070.00017.18
8.0.280.0030.00318.46
8.0.270.0070.00017.18
8.0.260.0060.00018.53
8.0.250.0070.00017.03
8.0.240.0030.00516.90
8.0.230.0030.00316.93
8.0.220.0000.00716.96
8.0.210.0040.00416.94
8.0.200.0000.00716.94
8.0.190.0040.00416.98
8.0.180.0070.00016.89
8.0.170.0030.00616.97
8.0.160.0040.00416.96
8.0.150.0000.00816.85
8.0.140.0040.00416.93
8.0.130.0030.00313.39
8.0.120.0020.00516.90
8.0.110.0050.00217.00
8.0.100.0030.00517.05
8.0.90.0040.00417.00
8.0.80.0100.00616.90
8.0.70.0000.00716.93
8.0.60.0070.00016.89
8.0.50.0040.00416.92
8.0.30.0160.00417.26
8.0.20.0050.01317.40
8.0.10.0070.00017.02
8.0.00.0090.00816.77
7.4.330.0000.00615.00
7.4.320.0050.00316.61
7.4.300.0060.00016.62
7.4.290.0000.00716.57
7.4.280.0000.00816.48
7.4.270.0040.00416.54
7.4.260.0000.00716.36
7.4.250.0030.00516.48
7.4.240.0000.00716.51
7.4.230.0030.00316.59
7.4.220.0160.00916.63
7.4.210.0090.00816.67
7.4.200.0040.00416.63
7.4.190.0050.00216.77
7.4.160.0070.01016.44
7.4.150.0080.01017.40
7.4.140.0140.00917.86
7.4.130.0150.00216.62
7.4.120.0100.01016.70
7.4.110.0040.01316.55
7.4.100.0090.00916.52
7.4.90.0150.00416.52
7.4.80.0090.00919.39
7.4.70.0100.00616.54
7.4.60.0070.01016.73
7.4.50.0060.00316.28
7.4.40.0070.00822.77
7.4.30.0080.00816.76
7.4.00.0090.00814.85
7.3.330.0000.00513.43
7.3.320.0050.00013.37
7.3.310.0050.00216.27
7.3.300.0070.00016.37
7.3.290.0110.00716.32
7.3.280.0060.01116.39
7.3.270.0040.01317.40
7.3.260.0070.01116.50
7.3.250.0090.00816.42
7.3.240.0170.00416.49
7.3.230.0060.00916.39
7.3.210.0070.01116.46
7.3.200.0110.01319.39
7.3.190.0060.01216.47
7.3.180.0060.00916.43
7.3.170.0080.00816.63
7.3.160.0030.01216.42
7.3.120.0100.00715.00
7.3.110.0000.01914.77
7.3.100.0090.00615.15
7.3.90.0070.00714.73
7.3.80.0070.00714.87
7.3.70.0100.00314.91
7.3.60.0000.01314.89
7.3.50.0040.01115.02
7.3.40.0000.01114.62
7.3.30.0060.00914.98
7.3.20.0070.00716.46
7.3.10.0120.00316.85
7.3.00.0000.00916.75
7.2.330.0070.01516.51
7.2.320.0120.00616.72
7.2.310.0080.00816.80
7.2.300.0030.01316.86
7.2.290.0070.01016.88
7.2.250.0100.01014.96
7.2.240.0070.01015.02
7.2.230.0120.00315.17
7.2.220.0130.00314.93
7.2.210.0060.00915.14
7.2.200.0120.00315.13
7.2.190.0030.01015.04
7.2.180.0000.01014.82
7.2.170.0110.00315.24
7.2.80.0180.00915.91
7.2.60.0070.00716.78
7.2.00.0060.00619.63
7.1.330.0030.01015.89
7.1.320.0070.00715.87
7.1.310.0030.01115.68
7.1.300.0060.00615.79
7.1.290.0050.00515.90
7.1.280.0070.01015.75
7.1.270.0030.00915.65
7.1.260.0070.01015.60
7.1.200.0070.00715.88
7.1.100.0060.00618.18
7.1.70.0050.00217.11
7.1.60.0070.01719.33
7.1.50.0030.01316.91
7.1.00.0030.07722.40
7.0.200.0140.00414.73
7.0.140.0070.06721.95
7.0.60.0130.07020.03
7.0.50.0100.04717.95
7.0.40.0130.07720.40
7.0.30.0530.07020.33
7.0.20.0230.07720.32
7.0.10.0070.10020.25
7.0.00.0100.08020.33
5.6.280.0000.07721.13
5.6.210.0070.08020.63
5.6.200.0030.04318.24
5.6.190.0030.04320.60
5.6.180.0230.08320.57
5.6.170.0200.05020.56
5.6.160.0130.08720.43
5.6.150.0070.04018.18
5.6.140.0070.08318.28
5.6.130.0030.06718.28
5.6.120.0200.06721.02
5.6.110.0130.06721.13
5.6.100.0070.07021.09
5.6.90.0170.07321.08
5.6.80.0100.06020.29
5.6.70.4330.04320.43
5.5.350.0100.05320.34
5.5.340.0130.04017.95
5.5.330.0000.04720.19
5.5.320.0000.05720.27
5.5.310.0270.06320.31
5.5.300.0070.08717.98
5.5.290.0000.06017.95
5.5.280.0030.09020.80
5.5.270.0030.08720.77
5.5.260.0070.06320.79
5.5.250.0100.08320.58
5.5.240.0170.07720.19
5.4.450.0170.05319.55
5.4.440.0370.07319.36
5.4.430.0230.06319.38
5.4.420.0170.06719.55
5.4.410.0230.05719.34
5.4.400.0270.05019.25
5.4.390.0270.05319.23
5.4.380.0170.06318.79
5.4.370.0370.06718.73
5.4.360.0400.05318.80
5.4.350.0200.06718.58
5.4.340.0500.05318.51
5.4.320.0080.04212.51
5.4.310.0130.03612.51
5.4.300.0030.03812.51
5.4.290.0080.03512.50
5.4.280.0080.04312.38
5.4.270.0070.03812.38
5.4.260.0080.03812.38
5.4.250.0070.04312.38
5.4.240.0160.05712.38
5.4.230.0100.06212.36
5.4.220.0070.03612.37
5.4.210.0080.03712.37
5.4.200.0060.04212.37
5.4.190.0080.04212.36
5.4.180.0090.03812.37
5.4.170.0090.03512.37
5.4.160.0110.03312.37
5.4.150.0100.03412.36
5.4.140.0090.03812.05
5.4.130.0070.03812.04
5.4.120.0060.03711.99
5.4.110.0090.05011.99
5.4.100.0080.04111.99
5.4.90.0070.04111.99
5.4.80.0100.03511.98
5.4.70.0030.04611.98
5.4.60.0050.04411.99
5.4.50.0090.03211.99
5.4.40.0080.03511.98
5.4.30.0120.04111.97
5.4.20.0100.05011.97
5.4.10.0110.04211.97
5.4.00.0070.03711.46
5.3.290.0070.03812.80
5.3.280.0100.03812.71
5.3.270.0140.04512.73
5.3.260.0110.03612.72
5.3.250.0060.03912.72
5.3.240.0090.03612.72
5.3.230.0080.04112.71
5.3.220.0060.05612.68
5.3.210.0070.05712.68
5.3.200.0090.05012.68
5.3.190.0090.05112.68
5.3.180.0100.03712.68
5.3.170.0060.04112.67
5.3.160.0110.05012.68
5.3.150.0100.03712.68
5.3.140.0100.06012.66
5.3.130.0070.05112.66
5.3.120.0070.05612.66
5.3.110.0070.05612.66
5.3.100.0050.05312.12
5.3.90.0050.05812.09
5.3.80.0100.04912.08
5.3.70.0070.03812.07
5.3.60.0110.03212.06
5.3.50.0060.03912.00
5.3.40.0100.03612.00
5.3.30.0060.03811.95
5.3.20.0050.04411.74
5.3.10.0110.03311.71
5.3.00.0070.04311.69
5.2.170.0070.0369.18
5.2.160.0060.0299.18
5.2.150.0050.0319.18
5.2.140.0050.0419.18
5.2.130.0050.0299.14
5.2.120.0040.0319.13
5.2.110.0050.0379.14
5.2.100.0080.0279.14
5.2.90.0070.0399.14
5.2.80.0080.0449.14
5.2.70.0060.0369.14
5.2.60.0070.0539.09
5.2.50.0090.0449.06
5.2.40.0110.0359.03
5.2.30.0040.0439.02
5.2.20.0050.0309.01
5.2.10.0030.0318.92
5.2.00.0080.0368.78
5.1.60.0060.0288.06
5.1.50.0060.0288.06
5.1.40.0050.0258.04
5.1.30.0030.0288.40
5.1.20.0050.0268.41
5.1.10.0050.0268.13
5.1.00.0050.0258.13
5.0.50.0030.0226.61
5.0.40.0010.0236.48
5.0.30.0030.0316.29
5.0.20.0030.0196.26
5.0.10.0020.0216.24
5.0.00.0030.0336.23
4.4.90.0020.0204.78
4.4.80.0020.0204.75
4.4.70.0050.0184.75
4.4.60.0030.0204.75
4.4.50.0030.0244.77
4.4.40.0060.0344.71
4.4.30.0060.0214.76
4.4.20.0060.0194.84
4.4.10.0070.0174.85
4.4.00.0020.0334.76
4.3.110.0000.0184.67
4.3.100.0040.0134.67
4.3.90.0020.0154.64
4.3.80.0020.0244.59
4.3.70.0020.0174.63
4.3.60.0040.0234.63
4.3.50.0040.0214.63
4.3.40.0030.0354.53
4.3.30.0020.0243.29
4.3.20.0060.0243.27
4.3.10.0030.0223.23
4.3.00.0330.01310.37

preferences:
40.47 ms | 400 KiB | 5 Q