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.60.0120.00316.88
8.3.50.0140.00322.00
8.3.40.0140.00718.89
8.3.30.0100.00319.15
8.3.20.0040.00420.39
8.3.10.0030.00623.56
8.3.00.0040.00419.38
8.2.180.0090.00617.00
8.2.170.0140.00322.96
8.2.160.0100.00320.35
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0160.00326.16
8.2.120.0080.00022.02
8.2.110.0030.00722.29
8.2.100.0040.00817.97
8.2.90.0030.00519.09
8.2.80.0040.00418.03
8.2.70.0070.00417.75
8.2.60.0060.00317.89
8.2.50.0040.00418.07
8.2.40.0000.00818.34
8.2.30.0030.00618.12
8.2.20.0000.00817.84
8.2.10.0070.00018.21
8.2.00.0030.00617.71
8.1.280.0040.01125.92
8.1.270.0080.00022.09
8.1.260.0040.00426.35
8.1.250.0000.00728.09
8.1.240.0060.00323.84
8.1.230.0070.00419.28
8.1.220.0030.00617.74
8.1.210.0060.00318.77
8.1.200.0060.00317.38
8.1.190.0000.00717.53
8.1.180.0080.00018.10
8.1.170.0040.00418.71
8.1.160.0040.00422.08
8.1.150.0040.00418.67
8.1.140.0040.00417.54
8.1.130.0000.00717.86
8.1.120.0040.00417.47
8.1.110.0020.00517.50
8.1.100.0050.00317.47
8.1.90.0050.00317.53
8.1.80.0040.00417.39
8.1.70.0030.00317.41
8.1.60.0030.00717.61
8.1.50.0040.00417.55
8.1.40.0000.00917.61
8.1.30.0030.00617.61
8.1.20.0050.00517.57
8.1.10.0060.00317.55
8.1.00.0050.00317.48
8.0.300.0080.00018.77
8.0.290.0070.00017.05
8.0.280.0000.00818.47
8.0.270.0070.00017.32
8.0.260.0000.00617.24
8.0.250.0000.00716.95
8.0.240.0030.00617.09
8.0.230.0030.00417.01
8.0.220.0000.00716.97
8.0.210.0000.00716.97
8.0.200.0000.00616.91
8.0.190.0070.00016.91
8.0.180.0000.00816.97
8.0.170.0060.00317.02
8.0.160.0050.00317.05
8.0.150.0080.00017.02
8.0.140.0000.00817.00
8.0.130.0000.00713.34
8.0.120.0000.00816.84
8.0.110.0040.00417.05
8.0.100.0000.00816.86
8.0.90.0000.00716.95
8.0.80.0100.00616.94
8.0.70.0050.00216.84
8.0.60.0040.00416.85
8.0.50.0040.00416.80
8.0.30.0050.01617.14
8.0.20.0110.00717.40
8.0.10.0040.00417.00
8.0.00.0070.00916.78
7.4.330.0000.00515.00
7.4.320.0030.00316.63
7.4.300.0060.00016.57
7.4.290.0070.00016.52
7.4.280.0000.00716.44
7.4.270.0000.00716.56
7.4.260.0030.00316.48
7.4.250.0040.00416.59
7.4.240.0020.00516.47
7.4.230.0030.00316.50
7.4.220.0100.00716.57
7.4.210.0130.00616.66
7.4.200.0030.00316.63
7.4.190.0030.00516.78
7.4.160.0100.00616.44
7.4.150.0150.00717.40
7.4.140.0170.00717.86
7.4.130.0090.00816.63
7.4.120.0120.00816.63
7.4.110.0060.01016.53
7.4.100.0090.00816.57
7.4.90.0060.01116.65
7.4.80.0100.01019.39
7.4.70.0140.00316.51
7.4.60.0040.01316.56
7.4.50.0030.00616.42
7.4.40.0030.01422.77
7.4.30.0090.00916.70
7.4.00.0070.01014.99
7.3.330.0050.00013.42
7.3.320.0000.00613.44
7.3.310.0050.00316.25
7.3.300.0070.00016.46
7.3.290.0140.00716.39
7.3.280.0110.00716.42
7.3.270.0070.01017.40
7.3.260.0150.00616.45
7.3.250.0140.00516.47
7.3.240.0070.01416.45
7.3.230.0080.00816.39
7.3.210.0080.00816.46
7.3.200.0110.01119.39
7.3.190.0110.00716.39
7.3.180.0060.00916.59
7.3.170.0090.00616.44
7.3.160.0050.01016.59
7.3.120.0050.01215.00
7.3.110.0060.01314.97
7.3.100.0060.01114.86
7.3.90.0070.00814.69
7.3.80.0040.00914.84
7.3.70.0050.00814.86
7.3.60.0100.00414.83
7.3.50.0060.00914.83
7.3.40.0080.00814.77
7.3.30.0060.00814.89
7.3.20.0060.01016.72
7.3.10.0020.00716.65
7.3.00.0040.00816.79
7.2.330.0090.00916.58
7.2.320.0100.00716.48
7.2.310.0030.01316.46
7.2.300.0060.01016.83
7.2.290.0090.01316.78
7.2.250.0040.01615.06
7.2.240.0070.01215.11
7.2.230.0070.00714.98
7.2.220.0060.00914.89
7.2.210.0070.00715.16
7.2.200.0050.01115.14
7.2.190.0060.00914.91
7.2.180.0060.00915.14
7.2.170.0060.00715.13
7.2.60.0110.00416.82
7.2.00.0090.00619.39
7.1.330.0090.00415.76
7.1.320.0030.00915.77
7.1.310.0050.00815.69
7.1.300.0100.00415.80
7.1.290.0050.00715.84
7.1.280.0040.01015.72
7.1.270.0080.00615.87
7.1.260.0020.01015.70
7.1.200.0030.00715.76
7.1.100.0000.00817.98
7.1.70.0040.00417.02
7.1.60.0130.01019.33
7.1.50.0110.00416.97
7.1.00.0070.07322.32
7.0.200.0060.00915.14
7.0.140.0100.06722.21
7.0.60.0100.08321.81
7.0.50.0070.05318.00
7.0.40.0170.05720.13
7.0.30.0430.07720.06
7.0.20.0170.04020.05
7.0.10.0070.08720.24
7.0.00.0030.08020.11
5.6.280.0030.07020.86
5.6.210.0100.08020.65
5.6.200.0130.06718.24
5.6.190.0070.06320.61
5.6.180.0230.04320.52
5.6.170.0270.08020.40
5.6.160.0070.04020.52
5.6.150.0170.06018.19
5.6.140.0030.07318.16
5.6.130.0000.04318.17
5.6.120.0070.04320.92
5.6.110.0170.06321.00
5.6.100.0100.07021.00
5.6.90.0100.03720.98
5.6.80.0030.09020.52
5.5.350.0200.07720.33
5.5.340.0070.06318.06
5.5.330.0030.08320.47
5.5.320.0000.04720.39
5.5.310.0330.04720.27
5.5.300.0000.04318.08
5.5.290.0100.03318.07
5.5.280.0200.06720.77
5.5.270.0070.08720.79
5.5.260.0030.08320.80
5.5.250.0070.08320.62
5.5.240.0370.06320.16
5.4.450.0130.06019.41
5.4.440.0230.07019.27
5.4.430.0230.04019.53
5.4.420.0200.06719.54
5.4.410.0200.06319.04
5.4.400.0130.07718.98
5.4.390.0270.07319.11
5.4.380.0270.07019.08
5.4.370.0170.04718.99
5.4.360.0200.06019.21
5.4.350.0270.04319.23
5.4.340.0200.08019.00
5.4.320.0270.07019.22
5.4.310.0100.04719.16
5.4.300.0230.04718.94
5.4.290.0270.06018.98
5.4.280.0230.07719.20
5.4.270.0370.06019.09
5.4.260.0300.06018.99
5.4.250.0170.04019.06
5.4.240.0270.07019.09
5.4.230.0230.06319.30
5.4.220.0200.04018.98
5.4.210.0230.03318.84
5.4.200.0200.03019.14
5.4.190.0130.04019.07
5.4.180.0130.03719.08
5.4.170.0170.03719.20
5.4.160.0130.04018.93
5.4.150.0100.04319.11
5.4.140.0130.03716.36
5.4.130.0130.03316.49
5.4.120.0130.03716.51
5.4.110.0130.03316.52
5.4.100.0170.03316.59
5.4.90.0130.03316.36
5.4.80.0170.04316.44
5.4.70.0130.03716.55
5.4.60.0130.03716.38
5.4.50.0130.03316.34
5.4.40.0130.03316.55
5.4.30.0200.03016.48
5.4.20.0130.03316.48
5.4.10.0030.04316.54
5.4.00.0100.04015.81
5.3.290.0230.07014.63
5.3.280.0230.03314.68
5.3.270.0130.03714.71
5.3.260.0130.04014.66
5.3.250.0130.03714.51
5.3.240.0170.04014.52
5.3.230.0100.04014.67
5.3.220.0130.03714.66
5.3.210.0130.03714.59
5.3.200.0130.03714.57
5.3.190.0170.03314.54
5.3.180.0130.03714.66
5.3.170.0170.04014.56
5.3.160.0270.04714.68
5.3.150.0130.04014.78
5.3.140.0100.04014.63
5.3.130.0100.04014.57
5.3.120.0170.03314.66
5.3.110.0130.03714.52
5.3.100.0270.03714.05
5.3.90.0130.03713.95
5.3.80.0130.03314.09
5.3.70.0130.03713.94
5.3.60.0170.03313.97
5.3.50.0100.04013.87
5.3.40.0230.04014.11
5.3.30.0200.05314.09
5.3.20.0200.07013.70
5.3.10.0300.03713.52
5.3.00.0270.06013.53
5.2.170.0070.03712.02
5.2.160.0170.06012.02
5.2.150.0200.04312.02
5.2.140.0230.05312.02
5.2.130.0170.05712.02
5.2.120.0170.04312.02
5.2.110.0130.06012.02
5.2.100.0170.04712.02
5.2.90.0170.04712.02
5.2.80.0200.03712.02
5.2.70.0200.04712.02
5.2.60.0200.07012.02
5.2.50.0270.05312.02
5.2.40.0330.02012.02
5.2.30.0130.04012.02
5.2.20.0170.05712.02
5.2.10.0200.05012.02
5.2.00.0170.03712.02
5.1.60.0070.04012.02
5.1.50.0200.04712.02
5.1.40.0200.04012.02
5.1.30.0100.05012.02
5.1.20.0130.04012.02
5.1.10.0100.04312.02
5.1.00.0130.05312.02
5.0.50.0100.04312.02
5.0.40.0070.04312.02
5.0.30.0030.06312.02
5.0.20.0130.04012.02
5.0.10.0100.04012.02
5.0.00.0030.06012.02
4.4.90.0100.02712.02
4.4.80.0130.03012.02
4.4.70.0030.04012.02
4.4.60.0070.03012.02
4.4.50.0070.03312.02
4.4.40.0070.05712.02
4.4.30.0100.03312.02
4.4.20.0070.02712.02
4.4.10.0030.02012.02
4.4.00.0070.02712.02
4.3.110.0100.03012.02
4.3.100.0100.03012.02
4.3.90.0070.03712.02
4.3.80.0100.03312.02
4.3.70.0070.02712.02
4.3.60.0000.03312.02
4.3.50.0030.03712.02
4.3.40.0100.04712.02
4.3.30.0030.04012.02
4.3.20.0000.03712.02
4.3.10.0030.02312.02
4.3.00.0030.03312.02

preferences:
32.78 ms | 401 KiB | 5 Q