3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getTree($treeByParent, $treeByCat, $id, $listed = []) { $gTree = []; $gTree[] = $id; $gTree[] = $treeByCat[ $id ]; /** if ( count($treeByParent[ $id ]) > 0) { foreach ($treeByParent[ $id ] as $cat) $gTree[] = $cat; } */ if ( count($treeByParent[ $treeByCat[ $id ] ]) > 0 ) $gTree = array_merge( getTree($treeByParent, $treeByCat, $treeByCat[ $id ]), $gTree); 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.40.0170.00318.97
8.3.30.0090.00619.19
8.3.20.0000.00720.29
8.3.10.0080.00023.56
8.3.00.0040.00419.25
8.2.170.0110.00722.96
8.2.160.0070.00720.35
8.2.150.0080.00024.18
8.2.140.0000.00724.66
8.2.130.0070.00726.16
8.2.120.0080.00022.27
8.2.110.0040.00421.96
8.2.100.0110.00017.91
8.2.90.0000.00819.19
8.2.80.0020.00517.97
8.2.70.0030.00717.75
8.2.60.0050.00317.80
8.2.50.0000.00918.07
8.2.40.0040.00418.34
8.2.30.0060.00318.02
8.2.20.0000.00817.84
8.2.10.0040.00418.13
8.2.00.0030.00617.88
8.1.270.0000.00822.19
8.1.260.0040.00426.35
8.1.250.0020.00528.09
8.1.240.0030.00624.02
8.1.230.0080.00319.16
8.1.220.0040.00417.79
8.1.210.0080.00018.77
8.1.200.0040.00417.38
8.1.190.0030.00517.66
8.1.180.0080.00018.10
8.1.170.0000.00818.44
8.1.160.0040.00422.02
8.1.150.0000.00718.76
8.1.140.0040.00417.47
8.1.130.0070.00017.84
8.1.120.0000.00717.47
8.1.110.0050.00317.52
8.1.100.0020.00517.36
8.1.90.0080.00017.48
8.1.80.0080.00017.49
8.1.70.0040.00417.48
8.1.60.0040.00417.61
8.1.50.0040.00417.40
8.1.40.0000.00717.55
8.1.30.0000.00817.64
8.1.20.0060.00317.68
8.1.10.0080.00017.44
8.1.00.0000.00717.60
8.0.300.0070.00018.77
8.0.290.0040.00417.05
8.0.280.0000.00718.39
8.0.270.0080.00017.13
8.0.260.0060.00017.15
8.0.250.0000.00816.91
8.0.240.0000.00716.84
8.0.230.0000.00717.01
8.0.220.0040.00416.90
8.0.210.0030.00316.88
8.0.200.0040.00416.90
8.0.190.0040.00417.02
8.0.180.0080.00017.05
8.0.170.0040.00417.03
8.0.160.0040.00416.85
8.0.150.0030.00316.95
8.0.140.0000.00816.93
8.0.130.0030.00313.41
8.0.120.0050.00316.90
8.0.110.0040.00416.86
8.0.100.0000.00817.03
8.0.90.0000.00717.02
8.0.80.0110.00316.98
8.0.70.0050.00216.96
8.0.60.0050.00216.97
8.0.50.0020.00516.78
8.0.30.0150.00717.27
8.0.20.0130.00517.40
8.0.10.0080.00017.09
8.0.00.0050.01316.90
7.4.330.0000.00515.20
7.4.320.0000.00616.48
7.4.300.0030.00316.51
7.4.290.0070.00016.50
7.4.280.0000.00916.65
7.4.270.0040.00416.53
7.4.260.0000.00616.45
7.4.250.0000.00716.38
7.4.240.0020.00616.49
7.4.230.0030.00316.50
7.4.220.0060.01216.72
7.4.210.0100.00816.56
7.4.200.0030.00316.62
7.4.190.0050.00216.33
7.4.160.0140.00316.62
7.4.150.0060.01917.40
7.4.140.0170.00617.86
7.4.130.0080.00816.38
7.4.120.0070.01016.44
7.4.110.0130.00316.64
7.4.100.0090.00916.61
7.4.90.0140.00416.57
7.4.80.0120.00819.39
7.4.70.0170.00916.52
7.4.60.0060.01216.34
7.4.50.0040.00416.28
7.4.40.0150.00322.77
7.4.30.0100.01016.45
7.4.00.0070.00714.97
7.3.330.0030.00313.34
7.3.320.0030.00313.29
7.3.310.0040.00416.46
7.3.300.0000.00616.38
7.3.290.0040.01116.38
7.3.280.0060.01016.42
7.3.270.0200.00017.40
7.3.260.0150.00316.43
7.3.250.0070.01116.44
7.3.240.0110.01016.36
7.3.230.0080.00816.52
7.3.210.0100.00716.51
7.3.200.0140.01019.39
7.3.190.0080.00816.52
7.3.180.0100.00616.38
7.3.170.0040.01216.44
7.3.160.0060.02016.50
7.3.120.0040.01114.95
7.2.330.0090.00916.59
7.2.320.0110.01116.70
7.2.310.0110.00516.52
7.2.300.0050.01116.66
7.2.290.0100.01016.71
7.2.80.0090.00416.70
7.2.60.0000.01016.93
7.2.50.0160.00316.82
7.2.00.0060.00919.53
7.1.200.0120.00315.80
7.1.100.0070.00718.08
7.1.70.0030.00917.02
7.1.60.0110.01419.33
7.1.50.0030.00716.90
7.1.00.0070.07322.43
7.0.200.0420.00414.67
7.0.140.0000.07721.95
7.0.110.0030.05020.11
7.0.100.0130.07720.07
7.0.90.0070.04019.93
7.0.80.0100.06720.08
7.0.70.0070.07019.93
7.0.60.0030.08320.05
7.0.50.0070.08019.97
7.0.40.0100.07319.74
7.0.30.0030.08719.71
7.0.20.0100.07719.82
7.0.10.0070.06019.82
7.0.00.0000.08019.82
5.6.280.0100.06721.13
5.6.260.0070.07320.69
5.6.250.0170.05720.70
5.6.240.0100.06020.73
5.6.230.0030.08720.72
5.6.220.0030.05720.61
5.6.210.0130.07320.62
5.6.200.0030.09020.59
5.6.190.0100.08020.61
5.6.180.0130.04020.62
5.6.170.0100.07020.52
5.6.160.0030.05720.61
5.6.150.0030.09020.86
5.6.140.0130.04020.65
5.6.130.0130.04720.64
5.6.120.0100.04020.61
5.6.110.0100.06720.65
5.6.100.0070.05320.64
5.6.90.0100.04320.60
5.6.80.0000.07719.99
5.6.70.0070.08020.02
5.6.60.0130.07019.96
5.6.50.0100.08020.01
5.6.40.0130.07319.94
5.6.30.0100.07719.93
5.6.20.0100.07320.00
5.6.10.0200.06720.01
5.6.00.0100.07720.04
5.5.380.0070.08317.68
5.5.370.0030.07717.54
5.5.360.0070.07317.55
5.5.350.0030.05317.61
5.5.340.0070.07018.13
5.5.330.0030.08317.95
5.5.320.0070.05018.23
5.5.310.0100.06318.22
5.5.300.0030.05317.93
5.5.290.0000.04318.13
5.5.280.0070.06718.09
5.5.270.0000.09018.12
5.5.260.0100.08018.05
5.5.250.0030.08317.75
5.5.240.0100.07317.30
5.5.230.0170.06717.31
5.5.220.0100.06717.21
5.5.210.0030.04717.34
5.5.200.0030.07317.46
5.5.190.0030.06717.18
5.5.180.0070.07717.28
5.5.160.0170.06717.29
5.5.150.0100.07017.28
5.5.140.0130.06717.28
5.5.130.0070.08017.18
5.5.120.0130.06717.45
5.5.110.0030.06017.43
5.5.100.0100.03317.36
5.5.90.0030.07717.32
5.5.80.0070.07017.08
5.5.70.0070.07717.36
5.5.60.0070.07017.35
5.5.50.0070.06717.33
5.5.40.0100.06717.47
5.5.30.0070.06717.19
5.5.20.0030.07717.19
5.5.10.0100.04017.19
5.5.00.0130.03717.33
5.4.450.0100.03719.35
5.4.440.0070.07319.50
5.4.430.0100.05319.33
5.4.420.0200.06319.46
5.4.410.0000.08319.20
5.4.400.0070.07719.24
5.4.390.0100.06719.02
5.4.380.0030.07719.00
5.4.370.0100.07018.95
5.4.360.0170.06719.31
5.4.350.0070.04319.00
5.4.340.0000.05019.17
5.4.320.0130.06718.99
5.4.310.0130.07018.97
5.4.300.0100.06719.11
5.4.290.0070.07019.18
5.4.280.0070.07719.24
5.4.270.0070.07319.00
5.4.260.0030.07319.22
5.4.250.0070.03319.10
5.4.240.0100.07319.22
5.4.230.0070.06719.33
5.4.220.0070.07719.13
5.4.210.0030.07319.18
5.4.200.0070.06319.00
5.4.190.0030.05719.16
5.4.180.0100.04019.00
5.4.170.0070.07719.23
5.4.160.0130.07319.15
5.4.150.0130.06718.98
5.4.140.0030.07316.34
5.4.130.0100.06716.38
5.4.120.0100.06016.39
5.4.110.0030.04016.52
5.4.100.0070.03716.44
5.4.90.0100.07016.41
5.4.80.0030.07316.55
5.4.70.0070.07016.36
5.4.60.0030.08316.65
5.4.50.0000.06016.54
5.4.40.0070.03716.50
5.4.30.0070.05016.47
5.4.20.0100.07016.44
5.4.10.0000.07016.39
5.4.00.0000.03315.88
5.3.290.0030.05314.63
5.3.280.0070.07714.62
5.3.270.0030.08014.60
5.3.260.0030.07014.70
5.3.250.0070.04714.74
5.3.240.0030.06014.62
5.3.230.0100.07314.48
5.3.220.0200.06014.71
5.3.210.0100.07014.59
5.3.200.0100.03714.65
5.3.190.0070.07314.59
5.3.180.0130.07014.56
5.3.170.0070.07714.80
5.3.160.0100.07014.54
5.3.150.0130.06714.56
5.3.140.0100.03314.51
5.3.130.0100.05714.68
5.3.120.0070.06714.56
5.3.110.0070.07314.53
5.3.100.0000.06014.01
5.3.90.0000.04314.04
5.3.80.0000.05013.99
5.3.70.0030.04314.09
5.3.60.0100.03714.07
5.3.50.0070.03013.90
5.3.40.0030.03013.92
5.3.30.0000.03313.93
5.3.20.0030.03313.71
5.3.10.0030.03713.63
5.3.00.0000.05313.64
5.2.170.0030.02711.88
5.2.160.0030.02711.88
5.2.150.0030.02711.88
5.2.140.0030.02311.88
5.2.130.0100.02011.88
5.2.120.0070.02311.88
5.2.110.0130.05311.88
5.2.100.0000.02711.88
5.2.90.0000.02711.88
5.2.80.0070.03011.88
5.2.70.0070.03011.88
5.2.60.0000.03311.88
5.2.50.0030.02711.88
5.2.40.0030.04011.88
5.2.30.0030.02711.88
5.2.20.0070.02711.88
5.2.10.0100.02311.88
5.2.00.0100.02711.88
5.1.60.0000.02711.88
5.1.50.0070.02011.88
5.1.40.0070.02011.88
5.1.30.0070.04711.88
5.1.20.0030.02711.88
5.1.10.0000.03011.88
5.1.00.0000.05011.88
5.0.50.0070.03311.88
5.0.40.0000.04311.88
5.0.30.0000.03011.88
5.0.20.0000.02011.88
5.0.10.0000.02011.88
5.0.00.0000.02711.88
4.4.90.0000.01311.88
4.4.80.0000.01711.88
4.4.70.0030.02711.88
4.4.60.0030.01311.88
4.4.50.0000.01311.88
4.4.40.0000.02311.88
4.4.30.0000.01711.88
4.4.20.0000.01711.88
4.4.10.0000.01311.88
4.4.00.0000.02711.88
4.3.110.0000.02011.88
4.3.100.0000.01311.88
4.3.90.0030.01311.88
4.3.80.0070.01711.88
4.3.70.0000.01311.88
4.3.60.0030.01311.88
4.3.50.0000.01711.88
4.3.40.0030.02311.88
4.3.30.0000.01711.88
4.3.20.0070.02011.88
4.3.10.0000.02711.88
4.3.00.0000.02711.88

preferences:
44.49 ms | 400 KiB | 5 Q