3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tree = array( 1 => array( 'parent_id' => null, 'name' => 'root', 'depth' => 0, ), 11 => array( 'parent_id' => 1, 'name' => 'a', 'depth' => 1, ), 12 => array( 'parent_id' => 1, 'name' => 'b', 'depth' => 1, ), 111 => array( 'parent_id' => 11, 'name' => 'aa', 'depth' => 2, ), 2 => array( 'parent_id' => null, 'name' => 'other root', 'depth' => 0, ) ); foreach ($tree as $key => &$sub) { if (isset($sub['parent_id'])) { $tree[$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 ($tree as $key => $sub) { if (isset($sub['parent_id'])) unset($tree[$key]); } var_dump($tree);

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.0110.00718.32
8.3.50.0130.00521.21
8.3.40.0030.01218.83
8.3.30.0040.01420.29
8.3.20.0040.00420.38
8.3.10.0080.00021.01
8.3.00.0080.00023.57
8.2.180.0070.01016.35
8.2.170.0150.00022.96
8.2.160.0140.00722.30
8.2.150.0060.00324.18
8.2.140.0050.00324.66
8.2.130.0000.00826.16
8.2.120.0070.00021.18
8.2.110.0060.00319.28
8.2.100.0090.00317.91
8.2.90.0040.00419.35
8.2.80.0080.00017.97
8.2.70.0000.00917.75
8.2.60.0080.00018.05
8.2.50.0000.00818.07
8.2.40.0040.00718.00
8.2.30.0080.00019.50
8.2.20.0040.00417.78
8.2.10.0030.00517.66
8.2.00.0050.00317.68
8.1.280.0060.01225.92
8.1.270.0080.00023.99
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0090.00023.94
8.1.230.0040.00720.97
8.1.220.0050.00318.77
8.1.210.0040.00418.97
8.1.200.0030.00717.48
8.1.190.0000.00917.53
8.1.180.0030.00618.10
8.1.170.0030.00618.71
8.1.160.0000.00718.80
8.1.150.0000.00718.55
8.1.140.0080.00017.36
8.1.130.0030.00317.87
8.1.120.0030.00617.33
8.1.110.0040.00417.42
8.1.100.0000.00817.48
8.1.90.0000.00717.44
8.1.80.0030.00317.42
8.1.70.0070.00017.36
8.1.60.0030.00617.54
8.1.50.0040.00417.52
8.1.40.0050.00317.51
8.1.30.0000.00917.56
8.1.20.0030.00617.68
8.1.10.0000.00717.51
8.1.00.0040.00417.46
8.0.300.0030.00519.84
8.0.290.0040.00417.17
8.0.280.0000.00718.32
8.0.270.0040.00417.25
8.0.260.0070.00016.82
8.0.250.0070.00016.93
8.0.240.0030.00616.84
8.0.230.0000.00716.83
8.0.220.0000.00816.89
8.0.210.0000.00816.80
8.0.200.0040.00416.91
8.0.190.0000.00716.93
8.0.180.0020.00516.92
8.0.170.0070.00016.96
8.0.160.0030.00316.94
8.0.150.0040.00416.82
8.0.140.0000.00716.75
8.0.130.0000.00713.33
8.0.120.0040.00416.82
8.0.110.0080.00016.69
8.0.100.0040.00416.86
8.0.90.0000.00816.95
8.0.80.0040.01116.92
8.0.70.0070.00016.84
8.0.60.0050.00216.74
8.0.50.0080.00016.75
8.0.30.0110.00916.95
8.0.20.0170.00717.40
8.0.10.0020.00517.05
8.0.00.0070.01216.71
7.4.330.0040.00415.00
7.4.320.0000.00716.51
7.4.300.0030.00316.54
7.4.290.0030.00316.64
7.4.280.0040.00416.64
7.4.270.0000.00716.48
7.4.260.0050.00013.23
7.4.250.0040.00416.52
7.4.240.0000.00716.61
7.4.230.0000.00716.48
7.4.220.0090.00916.57
7.4.210.0060.00916.51
7.4.200.0030.00316.63
7.4.190.0080.00016.59
7.4.160.0120.01216.54
7.4.150.0070.01117.40
7.4.140.0120.00817.86
7.4.130.0110.01016.51
7.4.120.0060.01616.44
7.4.110.0060.01116.80
7.4.100.0120.00616.58
7.4.90.0060.01616.54
7.4.80.0070.01719.39
7.4.70.0050.01116.60
7.4.60.0110.00716.47
7.4.50.0000.00816.63
7.4.40.0040.00822.77
7.4.30.0100.01316.44
7.4.00.0070.01014.88
7.3.330.0050.00013.25
7.3.320.0050.00013.25
7.3.310.0000.00716.14
7.3.300.0000.00716.33
7.3.290.0030.01016.33
7.3.280.0090.00716.29
7.3.270.0070.01017.40
7.3.260.0150.00518.24
7.3.250.0100.00916.31
7.3.240.0060.01316.35
7.3.230.0030.01516.39
7.3.210.0130.00416.60
7.3.200.0110.00719.39
7.3.190.0060.01916.39
7.3.180.0150.00616.36
7.3.170.0120.00616.54
7.3.160.0070.01116.31
7.3.120.0090.00614.92
7.3.110.0100.01015.09
7.3.100.0030.01715.04
7.3.90.0030.00814.55
7.3.80.0120.00314.85
7.3.70.0030.01514.78
7.3.60.0000.01315.00
7.3.50.0090.00614.54
7.3.40.0120.00014.84
7.3.30.0130.00014.54
7.3.20.0030.01016.55
7.3.10.0070.00716.52
7.3.00.0100.00516.51
7.2.330.0120.00916.60
7.2.320.0170.00716.75
7.2.310.0140.00716.42
7.2.300.0110.00516.70
7.2.290.0040.01316.70
7.2.250.0040.01515.23
7.2.240.0110.00715.32
7.2.230.0090.00615.19
7.2.220.0060.01015.18
7.2.210.0070.00715.08
7.2.200.0110.00014.86
7.2.190.0070.00715.05
7.2.180.0040.01415.12
7.2.170.0070.00315.11
7.2.160.0100.00314.89
7.2.150.0060.00617.00
7.2.140.0140.00317.13
7.2.130.0080.00716.78
7.2.120.0080.00716.72
7.2.110.0080.00516.84
7.2.100.0050.00816.81
7.2.90.0100.00316.91
7.2.80.0060.00816.87
7.2.70.0090.00616.81
7.2.60.0080.00816.84
7.2.50.0060.00816.80
7.2.40.0070.01216.91
7.2.30.0080.00716.82
7.2.20.0090.00616.78
7.2.10.0060.01016.83
7.2.00.0080.00816.90
7.1.330.0080.00615.88
7.1.320.0110.00715.98
7.1.310.0030.00715.95
7.1.300.0030.01015.75
7.1.290.0060.00615.88
7.1.280.0070.00715.83
7.1.270.0030.01015.78
7.1.260.0060.00615.77
7.1.250.0070.00515.75
7.1.240.0050.00615.72
7.1.230.0020.01115.76
7.1.220.0080.00515.73
7.1.210.0060.00815.76
7.1.200.0030.00815.79
7.1.190.0050.00815.76
7.1.180.0020.00915.80
7.1.170.0080.00615.82
7.1.160.0040.00715.69
7.1.150.0090.00315.86
7.1.140.0080.00715.84
7.1.130.0070.00615.64
7.1.120.0040.00815.73
7.1.110.0070.00615.80
7.1.100.0040.00815.75
7.1.90.0030.00715.80
7.1.80.0050.00615.76
7.1.70.0040.00816.05
7.1.60.0070.00616.66
7.1.50.0050.01116.18
7.1.40.0070.00815.81
7.1.30.0030.01015.87
7.1.20.0050.00715.75
7.1.10.0040.00915.67
7.1.00.0040.01617.45
7.0.330.0040.00715.27
7.0.320.0050.00815.31
7.0.310.0040.00715.34
7.0.300.0040.00615.43
7.0.290.0050.00715.41
7.0.280.0060.00715.34
7.0.270.0060.00715.37
7.0.260.0030.00915.35
7.0.250.0090.00415.42
7.0.240.0070.00515.48
7.0.230.0070.00715.40
7.0.220.0040.00715.48
7.0.210.0080.00515.32
7.0.200.0050.00715.68
7.0.190.0050.01015.53
7.0.180.0070.00515.23
7.0.170.0060.00615.42
7.0.160.0100.00415.43
7.0.150.0050.00915.38
7.0.140.0070.02017.10
7.0.130.0040.00915.37
7.0.120.0030.01115.33
7.0.110.0060.00615.23
7.0.100.0080.01716.58
7.0.90.0050.02516.55
7.0.80.0020.02916.48
7.0.70.0160.02216.59
7.0.60.0100.01816.48
7.0.50.0110.02516.67
7.0.40.0100.01215.03
7.0.30.0080.02515.18
7.0.20.0070.02414.96
7.0.10.0070.02415.05
7.0.00.0070.02415.10
5.6.400.0040.00814.65
5.6.390.0090.00314.07
5.6.380.0060.00814.36
5.6.370.0050.00714.51
5.6.360.0060.00714.48
5.6.350.0050.00714.60
5.6.340.0020.00814.40
5.6.330.0050.00914.42
5.6.320.0060.00714.63
5.6.310.0050.00914.46
5.6.300.0080.00614.54
5.6.290.0070.00614.38
5.6.280.0040.02316.05
5.6.270.0040.00914.38
5.6.260.0090.00714.24
5.6.250.0100.02016.00
5.6.240.0080.02615.87
5.6.230.0050.02816.06
5.6.220.0070.01615.98
5.6.210.0060.02215.84
5.6.200.0060.02616.00
5.6.190.0070.02516.01
5.6.180.0030.03015.95
5.6.170.0060.02215.98
5.6.160.0050.02416.03
5.6.150.0020.02016.03
5.6.140.0080.02316.00
5.6.130.0060.02615.97
5.6.120.0070.02516.07
5.6.110.0040.02016.03
5.6.100.0050.02516.05
5.6.90.0040.02415.90
5.6.80.0050.01815.92
5.6.70.0080.02115.78
5.6.60.0040.02715.76
5.6.50.0030.02815.65
5.6.40.0080.02015.87
5.6.30.0050.02415.95
5.6.20.0070.02315.85
5.6.10.0060.02415.82
5.6.00.0060.02615.81
5.5.380.0050.02614.32
5.5.370.0050.02114.31
5.5.360.0070.02314.34
5.5.350.0030.02214.31
5.5.340.0050.02314.32
5.5.330.0080.02214.34
5.5.320.0060.02014.34
5.5.310.0030.02814.48
5.5.300.0050.02614.43
5.5.290.0080.02514.44
5.5.280.0110.01814.32
5.5.270.0050.01814.24
5.5.260.0070.02214.34
5.5.250.0040.02514.25
5.5.240.0060.02114.17
5.5.230.0080.02014.22
5.5.220.0070.01214.21
5.5.210.0050.01614.12
5.5.200.0060.02514.19
5.5.190.0030.02814.14
5.5.180.0090.01914.10
5.5.170.0030.00812.10
5.5.160.0050.02414.11
5.5.150.0090.02114.14
5.5.140.0070.02514.07
5.5.130.0060.01614.11
5.5.120.0040.01614.09
5.5.110.0050.01614.12
5.5.100.0070.02514.15
5.5.90.0060.02314.15
5.5.80.0060.01714.03
5.5.70.0020.02014.26
5.5.60.0040.02514.11
5.5.50.0030.02614.13
5.5.40.0050.02014.01
5.5.30.0080.02014.04
5.5.20.0070.01314.15
5.5.10.0040.02214.11
5.5.00.0060.02014.05
5.4.450.0060.02313.49
5.4.440.0050.02413.50
5.4.430.0040.02613.51
5.4.420.0070.02213.49
5.4.410.0040.02313.37
5.4.400.0030.02113.42
5.4.390.0030.01713.51
5.4.380.0060.01713.34
5.4.370.0040.02313.32
5.4.360.0030.01713.24
5.4.350.0020.02713.38
5.4.340.0050.01313.45
5.4.330.0050.00411.43
5.4.320.0030.01513.34
5.4.310.0040.02513.32
5.4.300.0050.01613.39
5.4.290.0070.02313.45
5.4.280.0040.02613.43
5.4.270.0050.02213.29
5.4.260.0040.02013.43
5.4.250.0080.01513.35
5.4.240.0040.02313.39
5.4.230.0050.01613.29
5.4.220.0040.02313.49
5.4.210.0060.01913.39
5.4.200.0050.01413.39
5.4.190.0050.01613.30
5.4.180.0060.01913.42
5.4.170.0060.01513.40
5.4.160.0050.01813.34
5.4.150.0050.02013.38
5.4.140.0100.01812.75
5.4.130.0030.01812.72
5.4.120.0080.01812.67
5.4.110.0050.01912.80
5.4.100.0060.02212.79
5.4.90.0030.02312.62
5.4.80.0030.02112.69
5.4.70.0070.01412.69
5.4.60.0030.01512.69
5.4.50.0060.02012.73
5.4.40.0070.01112.70
5.4.30.0060.01312.71
5.4.20.0030.02512.71
5.4.10.0040.02512.66
5.4.00.0060.02012.59
5.3.290.0050.02212.25
5.3.280.0060.02112.16
5.3.270.0040.02212.17
5.3.260.0030.01812.19
5.3.250.0020.01712.18
5.3.240.0060.01812.15
5.3.230.0040.02512.14
5.3.220.0050.01812.06
5.3.210.0100.01712.09
5.3.200.0050.02312.07
5.3.190.0050.02312.13
5.3.180.0050.02112.20
5.3.170.0060.02212.17
5.3.160.0040.01512.16
5.3.150.0020.02012.14
5.3.140.0040.01512.12
5.3.130.0030.01612.17
5.3.120.0070.02012.12
5.3.110.0070.01912.15
5.3.100.0070.01412.04
5.3.90.0040.02212.03
5.3.80.0060.01811.98
5.3.70.0060.01411.96
5.3.60.0050.02112.00
5.3.50.0060.01111.96
5.3.40.0060.01311.95
5.3.30.0050.02111.97
5.3.20.0050.01911.82
5.3.10.0060.01911.87
5.3.00.0050.01911.86
5.2.170.0050.02410.87
5.2.160.0050.02210.82
5.2.150.0030.02210.86
5.2.140.0020.01710.79
5.2.130.0050.01110.84
5.2.120.0050.02510.79
5.2.110.0070.02210.79
5.2.100.0010.01610.83
5.2.90.0040.02110.79
5.2.80.0040.01610.82
5.2.70.0060.02110.82
5.2.60.0040.02310.84
5.2.50.0020.02610.79
5.2.40.0040.02410.76
5.2.30.0030.02510.82
5.2.20.0050.02010.79
5.2.10.0020.02010.72
5.2.00.0030.02410.69
5.1.60.0030.01910.48
5.1.50.0030.01910.47
5.1.40.0060.01010.41
5.1.30.0050.01910.60
5.1.20.0060.01910.62
5.1.10.0040.01710.50
5.1.00.0040.02010.46
5.0.50.0030.01210.09
5.0.40.0030.01810.09
5.0.30.0040.01910.09
5.0.20.0030.01610.09
5.0.10.0030.01510.09
5.0.00.0030.01810.09
4.4.90.0030.00910.09
4.4.80.0040.01210.09
4.4.70.0050.01110.09
4.4.60.0030.01210.09
4.4.50.0010.01510.09
4.4.40.0010.01310.09
4.4.30.0010.01110.09
4.4.20.0010.01610.09
4.4.10.0010.01210.09
4.4.00.0020.01310.09
4.3.110.0010.01310.09
4.3.100.0020.01210.09
4.3.90.0030.01010.09
4.3.80.0010.02110.09
4.3.70.0040.01310.09
4.3.60.0030.01010.09
4.3.50.0020.01110.09
4.3.40.0010.02010.09
4.3.30.0020.01510.09
4.3.20.0030.01110.09
4.3.10.0030.01210.09
4.3.00.0020.01310.09

preferences:
42.76 ms | 401 KiB | 5 Q