3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( 55 => array( 'ident' => 'test 1', 'depth' => 1, ), 77 => array( 'parent_id' => 55, 'ident' => 'test 2', 'depth' => 2, ), 109 => array( 'parent_id' => 77, 'ident' => 'test 3', 'depth' => 3, ), 78 => array( 'parent_id' => 55, 'ident' => 'test 4', 'depth' => 2, ), 25 => array( 'ident' => 'test 5', 'depth' => 1, ) ); foreach ($array as $key => &$sub) { if (isset($sub['parent_id'])) { $array[$sub['parent_id']]['children'][$key] = &$sub; } } unset($sub); // unset the reference to make sure to not overwrite it later... // now remove the entries with parents foreach ($array as $key => $sub) { if (isset($sub['parent_id'])) unset($array[$key]); } var_dump($array); print_r($array);

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.0090.00616.50
8.3.50.0150.00316.58
8.3.40.0070.00718.93
8.3.30.0180.00318.85
8.3.20.0040.00418.60
8.3.10.0070.00320.61
8.3.00.0000.00819.38
8.2.180.0090.00616.38
8.2.170.0110.00422.96
8.2.160.0070.00721.20
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0050.00321.01
8.2.110.0030.00720.94
8.2.100.0090.00317.72
8.2.90.0070.00319.34
8.2.80.0030.00519.15
8.2.70.0050.00317.63
8.2.60.0000.00817.80
8.2.50.0060.00318.07
8.2.40.0000.00818.34
8.2.30.0090.00018.09
8.2.20.0000.00717.62
8.2.10.0000.00817.75
8.2.00.0000.00817.65
8.1.280.0150.00325.92
8.1.270.0080.00024.66
8.1.260.0000.00826.35
8.1.250.0030.00528.09
8.1.240.0030.00622.54
8.1.230.0070.00421.04
8.1.220.0030.00517.79
8.1.210.0040.00418.91
8.1.200.0060.00317.35
8.1.190.0000.00917.53
8.1.180.0080.00318.10
8.1.170.0080.00018.95
8.1.160.0050.00318.97
8.1.150.0000.00718.63
8.1.140.0000.00717.32
8.1.130.0070.00017.88
8.1.120.0030.00517.51
8.1.110.0040.00417.46
8.1.100.0070.00017.33
8.1.90.0000.00717.49
8.1.80.0050.00217.47
8.1.70.0000.00717.45
8.1.60.0030.00617.60
8.1.50.0040.00417.45
8.1.40.0030.00617.56
8.1.30.0050.00317.68
8.1.20.0030.00617.66
8.1.10.0000.00817.45
8.1.00.0040.00417.36
8.0.300.0070.00019.82
8.0.290.0040.00416.75
8.0.280.0030.00318.44
8.0.270.0050.00217.36
8.0.260.0000.00716.86
8.0.250.0040.00416.80
8.0.240.0040.00416.88
8.0.230.0030.00316.96
8.0.220.0000.00716.80
8.0.210.0080.00016.84
8.0.200.0070.00016.95
8.0.190.0040.00416.84
8.0.180.0000.00816.89
8.0.170.0040.00416.91
8.0.160.0080.00016.94
8.0.150.0030.00616.87
8.0.140.0040.00516.80
8.0.130.0000.00513.31
8.0.120.0000.00716.88
8.0.110.0000.00716.88
8.0.100.0020.00516.77
8.0.90.0080.00016.78
8.0.80.0030.01316.90
8.0.70.0000.00816.76
8.0.60.0040.00416.88
8.0.50.0000.00716.90
8.0.30.0080.01216.95
8.0.20.0100.01417.06
8.0.10.0040.00417.00
8.0.00.0120.01116.83
7.4.330.0020.00212.96
7.4.320.0000.00616.39
7.4.300.0000.00716.59
7.4.290.0000.00716.60
7.4.280.0000.00916.54
7.4.270.0030.00316.65
7.4.260.0060.00013.33
7.4.250.0100.00016.50
7.4.240.0020.00516.55
7.4.230.0040.00416.43
7.4.220.0030.01516.65
7.4.210.0070.00816.58
7.4.200.0000.00716.71
7.4.190.0000.00716.57
7.4.160.0030.01316.39
7.4.150.0100.00916.60
7.4.140.0160.00316.58
7.4.130.0130.00716.44
7.4.120.0120.00616.54
7.4.110.0100.00716.34
7.4.100.0150.00616.53
7.4.90.0100.01016.58
7.4.80.0110.01119.39
7.4.70.0100.00716.47
7.4.60.0070.01016.40
7.4.50.0090.00616.30
7.4.40.0050.00716.34
7.4.30.0120.00616.18
7.4.00.0070.01014.73
7.3.330.0050.00313.16
7.3.320.0000.00613.09
7.3.310.0000.00716.26
7.3.300.0030.00316.36
7.3.290.0060.00916.27
7.3.280.0090.00516.33
7.3.270.0200.00616.53
7.3.260.0040.01516.57
7.3.250.0150.00516.38
7.3.240.0140.00516.45
7.3.230.0140.00416.32
7.3.210.0100.01016.20
7.3.200.0090.00916.50
7.3.190.0090.00916.45
7.3.180.0100.00716.55
7.3.170.0120.00616.36
7.3.160.0070.01016.45
7.3.120.0000.01514.93
7.3.10.0000.01616.63
7.3.00.0040.00916.75
7.2.330.0140.01016.69
7.2.320.0060.01816.56
7.2.310.0100.01016.51
7.2.300.0090.00816.73
7.2.290.0190.00616.61
7.2.130.0080.00416.96
7.2.120.0040.01116.79
7.2.110.0050.00816.63
7.2.100.0050.00516.80
7.2.90.0110.00716.92
7.2.80.0040.00816.87
7.2.70.0030.00716.57
7.2.60.0040.01017.02
7.2.50.0060.01016.83
7.2.40.0060.00316.73
7.2.30.0070.00716.48
7.2.20.0130.00616.46
7.2.10.0120.00316.64
7.2.00.0070.00817.99
7.1.250.0040.01115.83
7.1.100.0000.01218.30
7.1.70.0230.00417.22
7.1.60.0110.01119.40
7.1.50.0120.01216.63
7.1.00.0030.07322.48
7.0.200.0030.00616.77
7.0.140.0100.07022.21
7.0.120.0030.07022.04
7.0.60.0170.05719.87
7.0.50.0030.04017.86
7.0.40.0100.03719.96
7.0.30.0530.05020.17
7.0.20.0230.04320.23
7.0.10.0330.06020.22
7.0.00.0100.08020.23
5.6.210.0070.08720.51
5.6.200.0030.04018.18
5.6.190.0030.09320.77
5.6.180.0230.04720.47
5.6.170.0230.06720.71
5.6.160.0100.05020.54
5.6.150.0130.04318.18
5.6.140.0070.04018.18
5.6.130.0070.08018.29
5.6.120.0070.04321.05
5.6.110.0000.05020.97
5.6.100.0100.08020.88
5.6.90.0070.06320.94
5.6.80.0170.04020.37
5.6.70.0370.07720.39
5.5.350.0330.06720.39
5.5.340.0070.06317.99
5.5.330.0070.04020.40
5.5.320.0230.08320.19
5.5.310.0200.03720.34
5.5.300.0030.07017.98
5.5.290.0100.08017.95
5.5.280.0070.04020.77
5.5.270.0130.08320.97
5.5.260.0070.04720.76
5.5.250.0100.08320.46
5.5.240.0030.04020.11
5.4.450.0070.07319.57
5.4.440.0100.03719.25
5.4.430.0000.04319.58
5.4.420.0000.04319.46
5.4.410.0000.07319.35
5.4.400.0070.06319.28
5.4.390.0100.07019.26
5.4.380.0030.03718.85
5.4.370.0070.07719.15
5.4.360.0030.04318.92
5.4.350.0200.02319.15
5.4.340.0130.03719.25
5.4.320.0100.04019.12
5.4.310.0030.04319.12
5.4.300.0030.04319.23
5.4.290.0070.04019.20
5.4.280.0070.08019.15
5.4.270.0130.03319.14
5.4.260.0070.07719.25
5.4.250.0070.03718.91
5.4.240.0170.05019.11
5.4.230.0100.06019.14
5.4.220.0100.07319.23
5.4.210.0070.04719.09
5.4.200.0030.07719.14
5.4.190.0030.07319.23
5.4.180.0170.05319.23
5.4.170.0030.06719.14
5.4.160.0100.04719.13
5.4.150.0170.07018.82
5.4.140.0100.07016.36
5.4.130.0030.04716.37
5.4.120.0030.04316.42
5.4.110.0100.07016.28
5.4.100.0070.05716.43
5.4.90.0170.06316.49
5.4.80.0070.06016.51
5.4.70.0100.07016.39
5.4.60.0130.06716.41
5.4.50.0130.06316.42
5.4.40.0030.05316.39
5.4.30.0170.06016.39
5.4.20.0070.07016.30
5.4.10.0130.06016.39
5.4.00.0000.05315.95
5.3.290.0030.04314.70
5.3.280.0000.04714.59
5.3.270.0130.07314.76
5.3.260.0000.05714.63
5.3.250.0170.04714.49
5.3.240.0100.06014.68
5.3.230.0030.07714.59
5.3.220.0070.04714.45
5.3.210.0030.05314.52
5.3.200.0070.06014.63
5.3.190.0130.06714.59
5.3.180.0170.03314.61
5.3.170.0100.07314.60
5.3.160.0070.06014.62
5.3.150.0070.06714.58
5.3.140.0030.08014.64
5.3.130.0000.04314.60
5.3.120.0030.07714.46
5.3.110.0330.02314.54
5.3.100.0030.04014.09
5.3.90.0100.04014.16
5.3.80.0200.06014.16
5.3.70.0170.03314.07
5.3.60.0030.04714.01
5.3.50.0070.03714.09
5.3.40.0070.06313.95
5.3.30.0070.06313.94
5.3.20.0130.06713.74
5.3.10.0030.07013.70
5.3.00.0070.06713.64
5.2.170.0100.02311.04
5.2.160.0070.03711.09
5.2.150.0170.06311.11
5.2.140.0100.05311.19
5.2.130.0070.06311.25
5.2.120.0000.04011.05
5.2.110.0070.06011.10
5.2.100.0000.03711.05
5.2.90.0070.06011.16
5.2.80.0000.05311.01
5.2.70.0030.05311.13
5.2.60.0070.04010.94
5.2.50.0070.03310.97
5.2.40.0030.06311.15
5.2.30.0030.06311.02
5.2.20.0100.06010.87
5.2.10.0030.05711.00
5.2.00.0170.05010.77
5.1.60.0030.0539.91
5.1.50.0000.03010.04
5.1.40.0070.0239.91
5.1.30.0100.04710.30
5.1.20.0030.03310.39
5.1.10.0000.06310.09
5.1.00.0000.04010.09
5.0.50.0000.0378.60
5.0.40.0130.0378.38
5.0.30.0070.0308.20
5.0.20.0030.0278.11
5.0.10.0070.0238.17
5.0.00.0030.0638.21
4.4.90.0000.0238.07
4.4.80.0000.0378.07
4.4.70.0030.0208.07
4.4.60.0000.0378.07
4.4.50.0030.0338.07
4.4.40.0030.0508.07
4.4.30.0000.0308.07
4.4.20.0100.0308.07
4.4.10.0030.0338.07
4.4.00.0000.0408.07
4.3.110.0030.0378.07
4.3.100.0100.0308.07
4.3.90.0070.0278.07
4.3.80.0000.0438.07
4.3.70.0030.0378.07
4.3.60.0000.0338.07
4.3.50.0100.0138.07
4.3.40.0030.0508.07
4.3.30.0030.0338.07
4.3.20.0000.0238.07
4.3.10.0000.0308.07
4.3.00.0030.0338.07

preferences:
45.02 ms | 400 KiB | 5 Q