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( getParentAndChild($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.0150.00016.63
8.3.50.0140.00522.13
8.3.40.0110.00419.02
8.3.30.0000.01419.21
8.3.20.0080.00020.30
8.3.10.0040.00423.69
8.3.00.0030.00519.36
8.2.180.0120.00318.41
8.2.170.0060.01022.96
8.2.160.0090.00920.39
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0100.01026.16
8.2.120.0040.00422.14
8.2.110.0060.00322.25
8.2.100.0070.00717.84
8.2.90.0040.00419.29
8.2.80.0080.00017.97
8.2.70.0000.00817.63
8.2.60.0080.00017.93
8.2.50.0000.00918.07
8.2.40.0070.00318.22
8.2.30.0040.00418.02
8.2.20.0080.00017.63
8.2.10.0070.00018.13
8.2.00.0040.00717.74
8.1.280.0120.00925.92
8.1.270.0050.00322.24
8.1.260.0000.00726.35
8.1.250.0070.00028.09
8.1.240.0050.00523.82
8.1.230.0070.00419.10
8.1.220.0000.00817.79
8.1.210.0040.00418.77
8.1.200.0000.01117.35
8.1.190.0030.00517.65
8.1.180.0050.00318.10
8.1.170.0000.00818.41
8.1.160.0000.00722.02
8.1.150.0050.00318.66
8.1.140.0020.00517.57
8.1.130.0000.00717.84
8.1.120.0000.00717.51
8.1.110.0000.00817.50
8.1.100.0020.00517.45
8.1.90.0070.00017.41
8.1.80.0080.00017.53
8.1.70.0070.00017.32
8.1.60.0000.00717.50
8.1.50.0090.00017.56
8.1.40.0030.00617.50
8.1.30.0040.00417.58
8.1.20.0070.00017.55
8.1.10.0070.00017.62
8.1.00.0040.00417.53
8.0.300.0050.00318.77
8.0.290.0040.00416.92
8.0.280.0000.00718.39
8.0.270.0030.00317.14
8.0.260.0030.00317.18
8.0.250.0030.00316.84
8.0.240.0000.00716.95
8.0.230.0030.00316.84
8.0.220.0030.00616.82
8.0.210.0070.00016.81
8.0.200.0000.00616.83
8.0.190.0000.00916.84
8.0.180.0040.00416.81
8.0.170.0060.00316.81
8.0.160.0050.00316.95
8.0.150.0080.00016.93
8.0.140.0050.00216.86
8.0.130.0000.00613.29
8.0.120.0000.00716.91
8.0.110.0050.00316.80
8.0.100.0000.00716.94
8.0.90.0050.00316.99
8.0.80.0060.01616.95
8.0.70.0050.00216.88
8.0.60.0040.00416.89
8.0.50.0020.00516.81
8.0.30.0100.00817.09
8.0.20.0140.00617.40
8.0.10.0000.00816.96
8.0.00.0090.01016.82
7.4.330.0000.00615.00
7.4.320.0030.00316.54
7.4.300.0030.00316.51
7.4.290.0080.00016.56
7.4.280.0070.00016.63
7.4.270.0030.00516.44
7.4.260.0030.00316.61
7.4.250.0070.00016.50
7.4.240.0020.00616.49
7.4.230.0050.00216.51
7.4.220.0160.00316.59
7.4.210.0070.01116.53
7.4.200.0000.00816.41
7.4.190.0070.00016.77
7.4.160.0070.01316.63
7.4.150.0040.01317.40
7.4.140.0120.00917.86
7.4.130.0140.00316.66
7.4.120.0040.01316.54
7.4.110.0000.01616.48
7.4.100.0140.00716.45
7.4.90.0210.00016.35
7.4.80.0110.01219.39
7.4.70.0130.00316.64
7.4.60.0030.01316.39
7.4.50.0000.00816.51
7.4.40.0070.01122.77
7.4.30.0100.00716.37
7.4.00.0060.01015.05
7.3.330.0030.00313.39
7.3.320.0000.00613.36
7.3.310.0000.00716.39
7.3.300.0000.00716.33
7.3.290.0110.00616.41
7.3.280.0050.01116.38
7.3.270.0100.00917.40
7.3.260.0060.01016.41
7.3.250.0080.00916.40
7.3.240.0070.01416.31
7.3.230.0160.00316.39
7.3.210.0060.01216.44
7.3.200.0070.01019.39
7.3.190.0090.01216.47
7.3.180.0090.00616.68
7.3.170.0090.00616.64
7.3.160.0080.00816.67
7.3.120.0060.00914.70
7.3.10.0050.00516.68
7.3.00.0070.00616.67
7.2.330.0070.01016.84
7.2.320.0090.00916.81
7.2.310.0160.00616.69
7.2.300.0110.00716.81
7.2.290.0180.00316.54
7.2.130.0050.01316.92
7.2.120.0080.00616.79
7.2.110.0060.01016.88
7.2.100.0110.00516.98
7.2.90.0050.00716.89
7.2.80.0050.01116.82
7.2.70.0030.00816.97
7.2.60.0110.00416.98
7.2.50.0120.00616.87
7.2.40.0060.00616.98
7.2.30.0080.00517.06
7.2.20.0050.00917.06
7.2.10.0080.00417.06
7.2.00.0040.00717.65
7.1.250.0080.00615.86
7.1.240.0100.00016.04
7.1.230.0040.00715.83
7.1.220.0070.00715.71
7.1.210.0090.00615.64
7.1.200.0060.00515.84
7.1.190.0040.00715.64
7.1.180.0100.00315.82
7.1.170.0000.00915.69
7.1.160.0030.00915.90
7.1.150.0000.01315.75
7.1.140.0060.00615.82
7.1.130.0070.00315.91
7.1.120.0080.00315.90
7.1.110.0060.00615.77
7.1.100.0020.00816.86
7.1.90.0040.00715.75
7.1.80.0040.00715.70
7.1.70.0090.00516.36
7.1.60.0050.01117.57
7.1.50.0070.00716.39
7.1.40.0030.00815.82
7.1.30.0040.00815.74
7.1.20.0110.00315.73
7.1.10.0030.00815.71
7.1.00.0100.03518.98
7.0.330.0060.00615.25
7.0.320.0030.00915.36
7.0.310.0000.01415.28
7.0.300.0090.00615.17
7.0.290.0040.00715.42
7.0.280.0000.01215.24
7.0.270.0080.00415.48
7.0.260.0070.00315.37
7.0.250.0080.00315.55
7.0.240.0060.00615.41
7.0.230.0070.00715.53
7.0.220.0000.00815.28
7.0.210.0060.00615.50
7.0.200.0140.00515.12
7.0.190.0050.00315.46
7.0.180.0120.00315.43
7.0.170.0130.00315.37
7.0.160.0100.00315.41
7.0.150.0030.00815.33
7.0.140.0050.03918.83
7.0.130.0060.00615.37
7.0.120.0030.01215.31
7.0.110.0000.01615.55
7.0.100.0040.00415.53
7.0.90.0110.00415.53
7.0.80.0120.00015.13
7.0.70.0030.01315.40
7.0.60.0130.03317.48
7.0.50.0050.02516.52
7.0.40.0100.04716.92
7.0.30.0340.03316.89
7.0.20.0120.03016.93
7.0.10.0040.02816.78
7.0.00.0070.04416.75
5.6.380.0070.00714.72
5.6.370.0070.00414.82
5.6.360.0070.00714.75
5.6.350.0070.00714.38
5.6.340.0070.00314.31
5.6.330.0000.01214.08
5.6.320.0030.01114.52
5.6.310.0070.00714.20
5.6.300.0000.01014.31
5.6.290.0030.00914.14
5.6.280.0070.00714.41
5.6.270.0100.00014.64
5.6.260.0040.00814.40
5.6.250.0080.00414.51
5.6.240.0000.01414.41
5.6.230.0070.00314.37
5.6.220.0070.00414.39
5.6.210.0100.04017.42
5.6.200.0070.04316.43
5.6.190.0030.03917.39
5.6.180.1690.02617.70
5.6.170.0150.02217.55
5.6.160.0110.04117.50
5.6.150.0070.03716.43
5.6.140.0050.04316.18
5.6.130.0100.03216.29
5.6.120.0030.02317.64
5.6.110.0030.02717.79
5.6.100.0020.04817.73
5.6.90.0080.03817.52
5.6.80.0020.02417.38
5.6.70.0090.00614.26
5.6.60.0030.01314.31
5.6.50.0120.00014.36
5.6.40.0120.00614.56
5.6.30.0060.00914.51
5.6.20.0040.01214.32
5.6.10.0150.00014.51
5.6.00.0060.00914.43
5.5.380.0030.00311.29
5.5.370.0060.00611.46
5.5.360.0030.00911.29
5.5.350.0100.04415.81
5.5.340.0070.02714.74
5.5.330.0050.03215.81
5.5.320.0180.04715.78
5.5.310.0100.02515.77
5.5.300.0080.01914.63
5.5.290.0120.03714.57
5.5.280.0020.02716.03
5.5.270.0100.03715.97
5.5.260.0070.04016.00
5.5.250.0030.02215.91
5.5.240.0130.03915.67
5.5.230.0030.00611.20
5.5.220.0000.00911.24
5.5.210.0060.00611.41
5.5.200.0030.00311.29
5.5.190.0030.01011.18
5.5.180.0000.00611.18
5.5.170.0040.00811.18
5.5.160.0000.01111.18
5.5.150.0030.00711.37
5.5.140.0070.00411.18
5.5.130.0030.00911.34
5.5.120.0030.00911.18
5.5.110.0000.00811.27
5.5.100.0040.00411.18
5.5.90.0050.00511.32
5.5.80.0030.00711.43
5.5.70.0000.01011.18
5.5.60.0060.00611.30
5.5.50.0100.00011.18
5.5.40.0090.00311.24
5.5.30.0060.00311.18
5.5.20.0000.01211.39
5.5.10.0060.00611.18
5.5.00.0060.00311.18
5.4.450.0270.02815.36
5.4.440.0380.02515.40
5.4.430.0320.02015.43
5.4.420.0090.01915.44
5.4.410.0180.02315.25
5.4.400.0070.01815.31
5.4.390.0210.02015.19
5.4.380.0170.03014.89
5.4.370.0180.02915.04
5.4.360.0250.02514.90
5.4.350.0600.04214.91
5.4.340.0180.03314.98
5.4.330.0000.01111.18
5.4.320.0040.02511.84
5.4.310.0050.02511.84
5.4.300.0050.02411.88
5.4.290.0060.02511.91
5.4.280.0060.03011.78
5.4.270.0090.04311.78
5.4.260.0070.02911.78
5.4.250.0040.03111.78
5.4.240.0150.04611.84
5.4.230.0110.07711.80
5.4.220.0040.03311.77
5.4.210.0100.03011.77
5.4.200.0080.03211.78
5.4.190.0070.02311.77
5.4.180.0060.02111.77
5.4.170.0080.02011.77
5.4.160.0070.02011.77
5.4.150.0070.02611.77
5.4.140.0040.02211.73
5.4.130.0040.02211.61
5.4.120.0040.02111.62
5.4.110.0060.04111.59
5.4.100.0070.01911.62
5.4.90.0080.01911.59
5.4.80.0050.02211.59
5.4.70.0090.01811.68
5.4.60.0040.02211.63
5.4.50.0060.02811.58
5.4.40.0060.03711.57
5.4.30.0040.03011.65
5.4.20.0080.02611.64
5.4.10.0060.02611.60
5.4.00.0120.02811.32
5.3.290.0050.02411.99
5.3.280.0090.03311.94
5.3.270.0070.05411.95
5.3.260.0080.02811.95
5.3.250.0060.02011.95
5.3.240.0040.02311.95
5.3.230.0100.04011.94
5.3.220.0060.02811.93
5.3.210.0060.02811.93
5.3.200.0140.03211.93
5.3.190.0090.03511.93
5.3.180.0080.03811.92
5.3.170.0130.04611.92
5.3.160.0150.04311.93
5.3.150.0110.05611.92
5.3.140.0130.06611.92
5.3.130.0070.04111.92
5.3.120.0140.03411.92
5.3.110.0140.05611.92
5.3.100.0100.03111.64
5.3.90.0210.04311.63
5.3.80.0190.05711.63
5.3.70.0130.04111.63
5.3.60.0070.04111.62
5.3.50.0060.02811.59
5.3.40.0090.02711.59
5.3.30.0090.04111.57
5.3.20.0120.03911.46
5.3.10.0060.03011.45
5.3.00.0120.05011.44
5.2.170.0050.02510.19
5.2.160.0070.02610.19
5.2.150.0050.02410.19
5.2.140.0050.02610.19
5.2.130.0040.02110.17
5.2.120.0020.02510.17
5.2.110.0060.02110.17
5.2.100.0030.01810.17
5.2.90.0030.02310.17
5.2.80.0020.02110.17
5.2.70.0040.03410.17
5.2.60.0070.02410.14
5.2.50.0040.02010.13
5.2.40.0060.01710.12
5.2.30.0040.01910.11
5.2.20.0050.02110.10
5.2.10.0060.01710.05
5.2.00.0030.0189.99
5.1.60.0060.0149.63
5.1.50.0040.0169.63
5.1.40.0060.0139.62
5.1.30.0040.0169.79
5.1.20.0050.0179.81
5.1.10.0040.0179.67
5.1.00.0050.0159.67
5.0.50.0020.0158.91
5.0.40.0040.0128.84
5.0.30.0050.0178.74
5.0.20.0030.0128.73
5.0.10.0020.0138.72
5.0.00.0040.0188.71
4.4.90.0040.0127.98
4.4.80.0030.0147.96
4.4.70.0040.0147.96
4.4.60.0050.0087.97
4.4.50.0060.0107.97
4.4.40.0040.0217.94
4.4.30.0040.0117.97
4.4.20.0020.0148.01
4.4.10.0030.0108.01
4.4.00.0030.0147.96
4.3.110.0060.0077.92
4.3.100.0010.0127.92
4.3.90.0030.0087.90
4.3.80.0040.0137.88
4.3.70.0020.0097.90
4.3.60.0030.0097.90
4.3.50.0030.0097.90
4.3.40.0020.0157.86
4.3.30.0020.0117.24
4.3.20.0030.0097.24
4.3.10.0020.0137.21
4.3.00.0030.00712.32

preferences:
56.71 ms | 401 KiB | 5 Q