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[ $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.70.0120.00318.68
8.3.60.0140.00016.88
8.3.50.0070.01022.12
8.3.40.0150.00618.75
8.3.30.0040.01118.99
8.3.20.0080.00020.14
8.3.10.0040.00423.39
8.3.00.0000.00819.38
8.2.180.0070.00716.88
8.2.170.0120.00322.96
8.2.160.0040.01120.46
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0160.00326.16
8.2.120.0080.00022.20
8.2.110.0060.00322.16
8.2.100.0070.00317.84
8.2.90.0000.00819.27
8.2.80.0040.00417.97
8.2.70.0040.00817.63
8.2.60.0040.00418.04
8.2.50.0080.00018.07
8.2.40.0000.00818.34
8.2.30.0000.00718.09
8.2.20.0040.00417.84
8.2.10.0040.00418.20
8.2.00.0000.00817.75
8.1.280.0120.00325.92
8.1.270.0080.00022.19
8.1.260.0060.00326.35
8.1.250.0050.00328.09
8.1.240.0030.00623.92
8.1.230.0080.00420.84
8.1.220.0000.00817.74
8.1.210.0030.00518.77
8.1.200.0060.00317.36
8.1.190.0000.00917.63
8.1.180.0030.00518.10
8.1.170.0060.00318.57
8.1.160.0000.00821.92
8.1.150.0000.00818.73
8.1.140.0040.00417.47
8.1.130.0070.00017.90
8.1.120.0040.00417.42
8.1.110.0050.00317.50
8.1.100.0040.00417.49
8.1.90.0040.00417.48
8.1.80.0000.00917.48
8.1.70.0000.00717.41
8.1.60.0050.00317.61
8.1.50.0040.00417.45
8.1.40.0040.00417.44
8.1.30.0080.00017.55
8.1.20.0080.00017.71
8.1.10.0000.00817.45
8.1.00.0000.00717.41
8.0.300.0040.00418.77
8.0.290.0000.00717.16
8.0.280.0040.00418.29
8.0.270.0000.00717.16
8.0.260.0000.00717.14
8.0.250.0060.00016.90
8.0.240.0070.00016.93
8.0.230.0070.00017.00
8.0.220.0000.00716.96
8.0.210.0030.00316.89
8.0.200.0060.00016.87
8.0.190.0040.00417.07
8.0.180.0040.00417.05
8.0.170.0080.00017.01
8.0.160.0050.00316.88
8.0.150.0000.00716.98
8.0.140.0080.00016.91
8.0.130.0000.00713.35
8.0.120.0050.00316.90
8.0.110.0030.00516.98
8.0.100.0000.00716.89
8.0.90.0040.00417.00
8.0.80.0100.00916.95
8.0.70.0040.00417.05
8.0.60.0070.00016.86
8.0.50.0000.00717.04
8.0.30.0100.00816.82
8.0.20.0090.00917.40
8.0.10.0000.00816.98
8.0.00.0130.00616.86
7.4.330.0020.00215.00
7.4.320.0070.00016.52
7.4.300.0030.00316.64
7.4.290.0000.00816.68
7.4.280.0040.00416.50
7.4.270.0030.00316.55
7.4.260.0070.00016.47
7.4.250.0000.00716.54
7.4.240.0020.00516.50
7.4.230.0030.00316.45
7.4.220.0000.01716.72
7.4.210.0070.00916.66
7.4.200.0030.00316.64
7.4.190.0040.00416.70
7.4.160.0100.01016.36
7.4.150.0110.00617.40
7.4.140.0070.01217.86
7.4.130.0110.00616.53
7.4.120.0060.01016.43
7.4.110.0120.00616.63
7.4.100.0090.00916.48
7.4.90.0140.00316.60
7.4.80.0120.00919.39
7.4.70.0050.01516.61
7.4.60.0100.01316.76
7.4.50.0000.00816.68
7.4.40.0000.01522.77
7.4.30.0060.01416.59
7.4.00.0040.01214.80
7.3.330.0030.00313.36
7.3.320.0000.00513.37
7.3.310.0020.00516.17
7.3.300.0000.00716.33
7.3.290.0080.01116.38
7.3.280.0120.00616.36
7.3.270.0100.01017.40
7.3.260.0160.00716.53
7.3.250.0160.00616.38
7.3.240.0190.00316.27
7.3.230.0040.01616.56
7.3.210.0180.00016.33
7.3.200.0090.00919.39
7.3.190.0170.00016.48
7.3.180.0110.00516.35
7.3.170.0150.00016.62
7.3.160.0160.00016.36
7.3.120.0070.00714.87
7.2.330.0070.01016.80
7.2.320.0070.01016.75
7.2.310.0140.00316.42
7.2.300.0100.00616.47
7.2.290.0030.01316.86
7.2.60.0120.00016.77
7.2.00.0070.00719.14
7.1.200.0100.00315.89
7.1.100.0060.00618.19
7.1.70.0000.00817.28
7.1.60.0110.01419.33
7.1.50.0090.00616.63
7.1.00.0000.08022.28
7.0.200.0540.00614.93
7.0.140.0070.06721.99
7.0.110.0030.05019.96
7.0.100.0170.03720.09
7.0.90.0170.04719.97
7.0.80.0100.04719.94
7.0.70.0070.05019.96
7.0.60.0070.04720.04
7.0.50.0070.04319.95
7.0.40.0030.07019.73
7.0.30.0030.04319.88
7.0.20.0030.05719.77
7.0.10.0000.05319.77
7.0.00.0070.06319.86
5.6.280.0030.07020.89
5.6.260.0030.04720.51
5.6.250.0070.04320.89
5.6.240.0000.04320.65
5.6.230.0070.04020.69
5.6.220.0000.04020.63
5.6.210.0100.03020.68
5.6.200.0030.05020.57
5.6.190.0070.04320.63
5.6.180.0000.03720.57
5.6.170.0100.06020.56
5.6.160.0100.06020.65
5.6.150.0130.05020.56
5.6.140.0100.08020.64
5.6.130.0030.04020.56
5.6.120.0030.06720.66
5.6.110.0070.05020.65
5.6.100.0070.06720.60
5.6.90.0000.03720.66
5.6.80.0000.04319.90
5.6.70.0070.04019.99
5.6.60.0100.03719.96
5.6.50.0030.09719.94
5.6.40.0000.04720.02
5.6.30.0070.04720.22
5.6.20.0100.03720.00
5.6.10.0070.03719.95
5.6.00.0030.04720.04
5.5.380.0030.05017.69
5.5.370.0130.03717.71
5.5.360.0030.03717.52
5.5.350.0000.04017.65
5.5.340.0000.03717.91
5.5.330.0030.03318.10
5.5.320.0070.03317.96
5.5.310.0100.05318.09
5.5.300.0100.05317.83
5.5.290.0030.06018.13
5.5.280.0070.07018.13
5.5.270.0000.08318.04
5.5.260.0000.04718.13
5.5.250.0030.03718.04
5.5.240.0100.02717.30
5.5.230.0030.04717.29
5.5.220.0070.03717.53
5.5.210.0030.05717.48
5.5.200.0030.06017.45
5.5.190.0030.03717.27
5.5.180.0000.04317.61
5.5.160.0070.03317.61
5.5.150.0070.03717.41
5.5.140.0030.03017.48
5.5.130.0030.03017.45
5.5.120.0000.03317.44
5.5.110.0000.05017.48
5.5.100.0070.03717.36
5.5.90.0000.03717.36
5.5.80.0130.03017.47
5.5.70.0070.06017.12
5.5.60.0000.03317.17
5.5.50.0070.02717.07
5.5.40.0000.03717.38
5.5.30.0030.03717.15
5.5.20.0000.04717.49
5.5.10.0070.03717.32
5.5.00.0030.03017.50
5.4.450.0000.05019.34
5.4.440.0070.05719.27
5.4.430.0030.05319.33
5.4.420.0100.07319.41
5.4.410.0030.08019.38
5.4.400.0030.06718.99
5.4.390.0130.03319.36
5.4.380.0000.04018.98
5.4.370.0000.04719.31
5.4.360.0070.06018.99
5.4.350.0130.05719.01
5.4.340.0070.03719.00
5.4.320.0100.03318.97
5.4.310.0070.03319.01
5.4.300.0030.04319.01
5.4.290.0000.03318.95
5.4.280.0000.04319.03
5.4.270.0030.04019.03
5.4.260.0030.03319.24
5.4.250.0100.02719.18
5.4.240.0000.04019.23
5.4.230.0100.03319.22
5.4.220.0070.03019.33
5.4.210.0130.06319.02
5.4.200.0030.04019.22
5.4.190.0100.02318.96
5.4.180.0000.03719.23
5.4.170.0030.03719.23
5.4.160.0000.04318.99
5.4.150.0070.03019.17
5.4.140.0030.03716.59
5.4.130.0030.03016.33
5.4.120.0130.03316.28
5.4.110.0070.03316.54
5.4.100.0070.03716.59
5.4.90.0070.02716.45
5.4.80.0100.02716.46
5.4.70.0030.03016.47
5.4.60.0030.03016.48
5.4.50.0030.03016.50
5.4.40.0000.03316.45
5.4.30.0030.03016.43
5.4.20.0000.04016.62
5.4.10.0100.02316.52
5.4.00.0070.02715.87
5.3.290.0070.03014.68
5.3.280.0100.07014.57
5.3.270.0000.04014.46
5.3.260.0070.02714.61
5.3.250.0030.03714.76
5.3.240.0030.03714.73
5.3.230.0030.03014.57
5.3.220.0000.03314.58
5.3.210.0030.04014.58
5.3.200.0100.02714.43
5.3.190.0070.04014.57
5.3.180.0100.02714.60
5.3.170.0030.04314.70
5.3.160.0000.03314.64
5.3.150.0030.03314.54
5.3.140.0070.03714.57
5.3.130.0030.03714.63
5.3.120.0030.04014.77
5.3.110.0000.03714.59
5.3.100.0030.03314.27
5.3.90.0070.03014.14
5.3.80.0070.02713.87
5.3.70.0100.02314.04
5.3.60.0000.03313.94
5.3.50.0030.03714.17
5.3.40.0030.03014.03
5.3.30.0030.03013.91
5.3.20.0100.02313.64
5.3.10.0000.03013.79
5.3.00.0030.03013.59
5.2.170.0000.03312.30
5.2.160.0070.02012.30
5.2.150.0030.02712.30
5.2.140.0000.03012.30
5.2.130.0030.02312.30
5.2.120.0000.03312.30
5.2.110.0000.02712.30
5.2.100.0000.02712.30
5.2.90.0030.02312.30
5.2.80.0000.02712.30
5.2.70.0030.02312.30
5.2.60.0000.03012.30
5.2.50.0000.03312.30
5.2.40.0030.04312.30
5.2.30.0070.05012.30
5.2.20.0000.03712.30
5.2.10.0070.04012.30
5.2.00.0000.04712.30
5.1.60.0070.02712.30
5.1.50.0070.05312.30
5.1.40.0000.02712.30
5.1.30.0000.03012.30
5.1.20.0030.04312.30
5.1.10.0030.02712.30
5.1.00.0000.06012.30
5.0.50.0070.03012.30
5.0.40.0030.02012.30
5.0.30.0070.05312.30
5.0.20.0000.03012.30
5.0.10.0100.02012.30
5.0.00.0100.02712.30
4.4.90.0000.01312.30
4.4.80.0030.01712.30
4.4.70.0000.02312.30
4.4.60.0000.01312.30
4.4.50.0030.02012.30
4.4.40.0100.02012.30
4.4.30.0030.01312.30
4.4.20.0030.02312.30
4.4.10.0030.03012.30
4.4.00.0000.05312.30
4.3.110.0030.03012.30
4.3.100.0070.02312.30
4.3.90.0070.01712.30
4.3.80.0000.04312.30
4.3.70.0000.02712.30
4.3.60.0070.02312.30
4.3.50.0030.02012.30
4.3.40.0030.04712.30
4.3.30.0000.02012.30
4.3.20.0000.01712.30
4.3.10.0030.01312.30
4.3.00.0000.02012.30

preferences:
37.76 ms | 401 KiB | 5 Q