3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getParentAndChild($data, $id) { $tree = array( "parents" => array(), "children" => array(), "full" => array() ); $current = $data[$id]; $parent_id = $current === NULL ? "NULL" : $current; $child_ids = array($id); $tree['parents'][] = $parent_id; while (isset($data[$parent_id])) { $current = $data[$parent_id]; $parent_id = $current === NULL ? "NULL" : $current; $tree['parents'][] = $parent_id; } while ( count($child_ids) > 0 ) { foreach($child_ids as $child_id) { $children = array_keys($data, $child_id); foreach ($children as $child) $tree['children'][] = $child; $child_ids = $children; } } $tree['full'] = array_merge(array_reverse($tree['parents']), $tree['children']); echo implode(" > ", $tree['full']); } $treeByCat = array( 1 => 0, 2 => 0, 3 => 1, 7 => 1, 4 => 3, 5 => 4, 6 => 5, 8 => 5 ); print_r( display_parent_nodes($treeByCat, 4) ); //print_r( getTree($treeByParent, $treeByCat, 4, 0) );

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.0100.00716.63
8.3.50.0120.00722.10
8.3.40.0000.01418.70
8.3.30.0110.00318.84
8.3.20.0020.00520.34
8.3.10.0040.00423.61
8.3.00.0080.00019.25
8.2.180.0120.00318.44
8.2.170.0070.01422.96
8.2.160.0070.01420.52
8.2.150.0000.00824.18
8.2.140.0050.00224.66
8.2.130.0030.01426.16
8.2.120.0030.00522.26
8.2.110.0060.00322.27
8.2.100.0070.00617.91
8.2.90.0040.00419.09
8.2.80.0050.00317.97
8.2.70.0000.00917.63
8.2.60.0090.00017.93
8.2.50.0060.00318.07
8.2.40.0000.01118.03
8.2.30.0080.00017.99
8.2.20.0040.00417.75
8.2.10.0000.00819.81
8.2.00.0000.01017.69
8.1.280.0120.00325.92
8.1.270.0080.00023.92
8.1.260.0050.00226.35
8.1.250.0050.00228.09
8.1.240.0040.00423.97
8.1.230.0040.00719.10
8.1.220.0060.00317.74
8.1.210.0040.00418.77
8.1.200.0060.00317.35
8.1.190.0050.00317.50
8.1.180.0030.00618.10
8.1.170.0060.00318.46
8.1.160.0000.00721.98
8.1.150.0040.00418.63
8.1.140.0000.00717.39
8.1.130.0030.00317.78
8.1.120.0000.00717.40
8.1.110.0000.00717.43
8.1.100.0030.00317.37
8.1.90.0040.00417.40
8.1.80.0070.00017.41
8.1.70.0000.00717.40
8.1.60.0000.00717.42
8.1.50.0030.00617.55
8.1.40.0000.00717.46
8.1.30.0030.00617.48
8.1.20.0000.00717.68
8.1.10.0070.00017.60
8.1.00.0040.00417.40
8.0.300.0070.00018.77
8.0.290.0050.00317.15
8.0.280.0040.00418.30
8.0.270.0000.00717.27
8.0.260.0000.00617.20
8.0.250.0000.00617.01
8.0.240.0040.00416.95
8.0.230.0000.00716.88
8.0.220.0040.00416.89
8.0.210.0040.00416.92
8.0.200.0070.00016.95
8.0.190.0040.00416.86
8.0.180.0000.00716.79
8.0.170.0060.00316.89
8.0.160.0000.00816.98
8.0.150.0070.00316.83
8.0.140.0050.00316.88
8.0.130.0040.00413.32
8.0.120.0000.00816.82
8.0.110.0080.00016.80
8.0.100.0000.00716.94
8.0.90.0000.00716.93
8.0.80.0090.00616.86
8.0.70.0040.00416.76
8.0.60.0070.00016.77
8.0.50.0040.00416.90
8.0.30.0080.01017.04
8.0.20.0080.01117.40
8.0.10.0000.00817.13
8.0.00.0100.00816.63
7.4.330.0050.00015.00
7.4.320.0030.00316.56
7.4.300.0000.00616.63
7.4.290.0030.00316.45
7.4.280.0030.00316.59
7.4.270.0040.00416.53
7.4.260.0080.00016.62
7.4.250.0050.00216.58
7.4.240.0070.00016.56
7.4.230.0000.00716.41
7.4.220.0090.00916.59
7.4.210.0050.01016.54
7.4.200.0000.00716.65
7.4.190.0000.00716.70
7.4.160.0060.00916.37
7.4.150.0150.00817.40
7.4.140.0070.01217.86
7.4.130.0090.00816.52
7.4.120.0110.00616.51
7.4.110.0100.00716.37
7.4.100.0130.01016.35
7.4.90.0100.00716.53
7.4.80.0150.00919.39
7.4.70.0060.01116.57
7.4.60.0100.00616.61
7.4.50.0030.00616.32
7.4.40.0100.00722.77
7.4.30.0130.00516.41
7.4.00.0090.00314.96
7.3.330.0000.00513.14
7.3.320.0070.00013.30
7.3.310.0000.00716.13
7.3.300.0040.00416.17
7.3.290.0100.00316.32
7.3.280.0070.01016.29
7.3.270.0080.01117.40
7.3.260.0070.01016.55
7.3.250.0120.00716.56
7.3.240.0140.00316.30
7.3.230.0090.00916.39
7.3.210.0100.00716.46
7.3.200.0130.00619.39
7.3.190.0090.00616.34
7.3.180.0030.01316.38
7.3.170.0080.00816.50
7.3.160.0100.00616.47
7.3.120.0080.00814.98
7.2.330.0150.00716.54
7.2.320.0120.01216.50
7.2.310.0100.01016.54
7.2.300.0090.01216.30
7.2.290.0100.01316.62
7.2.60.0060.00616.53
7.1.200.0060.00615.47
7.1.70.0030.01316.97
7.1.60.0040.01119.33
7.1.50.0070.01416.57
7.1.00.0100.06722.48
7.0.200.0250.00814.63
7.0.140.0000.07321.95
7.0.60.0100.03320.07
7.0.50.0130.06717.98
7.0.40.0030.04320.11
7.0.30.0300.06720.34
7.0.20.0330.04020.19
7.0.10.0170.05720.22
7.0.00.0100.07320.07
5.6.280.0030.07321.00
5.6.210.0100.07020.63
5.6.200.0170.07318.19
5.6.190.0070.05320.64
5.6.180.0270.06720.55
5.6.170.0100.05720.54
5.6.160.0070.04320.54
5.6.150.0030.03718.16
5.6.140.0030.05018.16
5.6.130.0070.08718.15
5.6.120.0070.06321.00
5.6.110.0130.07721.12
5.6.100.0100.04021.02
5.6.90.0030.04321.14
5.6.80.0000.04020.39
5.5.350.4570.03020.53
5.5.340.0030.08717.95
5.5.330.0100.06020.47
5.5.320.0170.05720.27
5.5.310.0230.07020.36
5.5.300.0030.05718.13
5.5.290.0030.07017.95
5.5.280.0130.04720.80
5.5.270.0030.04320.80
5.5.260.0100.04020.98
5.5.250.0130.08720.55
5.5.240.0270.06720.13
5.4.450.0230.04019.41
5.4.440.0270.06719.55
5.4.430.0300.07019.41
5.4.420.0230.03719.52
5.4.410.0270.05319.39
5.4.400.0230.04318.85
5.4.390.0230.04019.31
5.4.380.0170.05019.14
5.4.370.0130.04319.08
5.4.360.0230.03319.09
5.4.350.0370.06018.95
5.4.340.0370.04019.23
5.4.320.0230.03719.09
5.4.310.0170.03719.25
5.4.300.0270.05318.94
5.4.290.0270.05719.08
5.4.280.0300.03719.14
5.4.270.0230.03019.13
5.4.260.0270.06718.97
5.4.250.0400.03719.31
5.4.240.0270.07019.00
5.4.230.0200.08019.08
5.4.220.0300.07019.15
5.4.210.0170.05019.08
5.4.200.0330.05319.08
5.4.190.0270.03719.15
5.4.180.0300.06719.21
5.4.170.0270.04719.14
5.4.160.0270.06719.07
5.4.150.0230.05019.22
5.4.140.0170.03716.50
5.4.130.0270.06316.34
5.4.120.0230.05016.33
5.4.110.0170.06716.37
5.4.100.0170.04716.54
5.4.90.0130.04016.29
5.4.80.0200.07316.44
5.4.70.0230.05016.49
5.4.60.0270.07016.50
5.4.50.0300.07016.51
5.4.40.0170.04016.43
5.4.30.0200.06016.32
5.4.20.0300.06316.42
5.4.10.0270.04016.42
5.4.00.0200.07315.85
5.3.290.0400.03714.60
5.3.280.0230.07014.52
5.3.270.0270.06714.63
5.3.260.0200.04714.54
5.3.250.0300.07014.73
5.3.240.0400.06014.73
5.3.230.0270.07314.61
5.3.220.0270.04014.65
5.3.210.0170.06014.63
5.3.200.0300.07014.69
5.3.190.0170.07014.72
5.3.180.0230.05014.58
5.3.170.0230.03714.65
5.3.160.0200.04714.48
5.3.150.0170.04014.62
5.3.140.0270.04014.64
5.3.130.0330.06314.61
5.3.120.0200.05314.64
5.3.110.0300.07314.69
5.3.100.0200.08013.93
5.3.90.0230.07313.99
5.3.80.0330.06314.04
5.3.70.0230.04713.94
5.3.60.0230.04314.07
5.3.50.0170.07714.08
5.3.40.0270.06713.97
5.3.30.0300.05014.14
5.3.20.0230.03713.63
5.3.10.0200.07013.75
5.3.00.0330.06013.66
5.2.170.0200.05312.30
5.2.160.0300.03012.30
5.2.150.0270.03312.30
5.2.140.0230.05312.30
5.2.130.0230.05312.30
5.2.120.0230.05012.30
5.2.110.0200.05712.30
5.2.100.0230.05312.30
5.2.90.0270.03312.30
5.2.80.0230.03712.30
5.2.70.0200.05712.30
5.2.60.0230.03712.30
5.2.50.0270.05312.30
5.2.40.0170.05012.30
5.2.30.0170.04712.30
5.2.20.0270.04312.30
5.2.10.0170.03712.30
5.2.00.0170.05012.30
5.1.60.0170.04712.30
5.1.50.0230.03712.30
5.1.40.0130.05312.30
5.1.30.0170.03012.30
5.1.20.0170.03712.30
5.1.10.0200.05312.30
5.1.00.0130.03712.30
5.0.50.0070.02712.30
5.0.40.0070.04712.30
5.0.30.0200.04312.30
5.0.20.0130.02012.30
5.0.10.0170.04012.30
5.0.00.0070.03712.30
4.4.90.0100.03312.30
4.4.80.0100.02312.30
4.4.70.0100.03312.30
4.4.60.0130.02012.30
4.4.50.0130.01312.30
4.4.40.0030.02712.30
4.4.30.0100.01712.30
4.4.20.0070.03712.30
4.4.10.0070.02312.30
4.4.00.0100.03312.30
4.3.110.0100.03312.30
4.3.100.0100.02712.30
4.3.90.0070.03312.30
4.3.80.0070.03312.30
4.3.70.0070.03712.30
4.3.60.0070.03012.30
4.3.50.0070.01712.30
4.3.40.0070.05312.30
4.3.30.0070.02712.30
4.3.20.0030.04012.30
4.3.10.0030.03012.30
4.3.00.0030.01712.30

preferences:
44.99 ms | 401 KiB | 5 Q