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, ) ); function v1($array) { 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]); } return $array; } var_dump(v1($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.0070.01418.68
8.3.50.0100.01021.09
8.3.40.0090.00618.97
8.3.30.0100.01018.84
8.3.20.0090.00018.48
8.3.10.0040.00421.09
8.3.00.0040.00420.50
8.2.180.0070.01116.75
8.2.170.0120.00322.96
8.2.160.0090.00520.35
8.2.150.0050.00324.18
8.2.140.0080.00024.66
8.2.130.0090.00026.16
8.2.120.0000.00821.18
8.2.110.0060.00320.57
8.2.100.0110.00017.72
8.2.90.0030.00619.35
8.2.80.0070.00019.37
8.2.70.0040.00917.38
8.2.60.0040.00418.03
8.2.50.0090.00018.07
8.2.40.0060.00318.22
8.2.30.0040.00419.35
8.2.20.0080.00017.65
8.2.10.0000.00717.64
8.2.00.0040.00417.66
8.1.280.0000.01525.92
8.1.270.0070.00023.99
8.1.260.0120.00626.35
8.1.250.0080.00028.09
8.1.240.0050.00322.61
8.1.230.0120.00020.89
8.1.220.0040.00418.77
8.1.210.0060.00318.81
8.1.200.0060.00317.35
8.1.190.0040.00417.53
8.1.180.0030.00518.10
8.1.170.0030.00518.48
8.1.160.0040.00418.91
8.1.150.0060.00318.64
8.1.140.0060.00317.52
8.1.130.0030.00317.74
8.1.120.0030.00317.36
8.1.110.0030.00517.46
8.1.100.0000.00717.43
8.1.90.0000.00717.47
8.1.80.0040.00417.49
8.1.70.0070.00017.41
8.1.60.0090.00017.58
8.1.50.0040.00417.54
8.1.40.0070.00017.54
8.1.30.0040.00417.54
8.1.20.0000.00817.68
8.1.10.0050.00317.61
8.1.00.0040.00417.57
8.0.300.0000.00819.84
8.0.290.0040.00417.28
8.0.280.0000.00718.35
8.0.270.0050.00217.26
8.0.260.0040.00416.78
8.0.250.0000.00817.02
8.0.240.0040.00416.84
8.0.230.0050.00316.95
8.0.220.0000.00716.86
8.0.210.0000.00716.90
8.0.200.0030.00316.92
8.0.190.0000.00816.96
8.0.180.0040.00416.90
8.0.170.0040.00416.89
8.0.160.0070.00016.91
8.0.150.0090.00016.91
8.0.140.0000.00716.79
8.0.130.0050.00013.33
8.0.120.0000.00816.81
8.0.110.0050.00316.79
8.0.100.0050.00216.70
8.0.90.0030.00516.96
8.0.80.0060.01016.92
8.0.70.0080.00016.77
8.0.60.0040.00416.90
8.0.50.0030.00516.93
8.0.30.0100.01017.06
8.0.20.0080.01417.40
8.0.10.0070.00016.99
8.0.00.0120.01316.82
7.4.330.0050.00016.82
7.4.320.0030.00316.53
7.4.300.0070.00016.52
7.4.290.0000.00716.52
7.4.280.0050.00216.55
7.4.270.0030.00316.54
7.4.260.0030.00313.28
7.4.250.0080.00016.57
7.4.240.0040.00416.60
7.4.230.0030.00316.39
7.4.220.0180.00716.57
7.4.210.0090.00716.57
7.4.200.0030.00316.64
7.4.190.0050.00316.50
7.4.160.0100.00716.46
7.4.150.0110.00717.40
7.4.140.0080.01017.86
7.4.130.0110.00816.40
7.4.120.0140.00516.42
7.4.110.0080.01516.58
7.4.100.0130.00416.61
7.4.90.0030.01516.61
7.4.80.0030.01719.39
7.4.70.0070.01016.42
7.4.60.0130.00316.48
7.4.50.0050.00516.13
7.4.40.0060.00922.77
7.4.30.0110.01116.44
7.4.00.0050.01214.94
7.3.330.0060.00013.16
7.3.320.0030.00313.39
7.3.310.0030.00316.40
7.3.300.0030.00316.29
7.3.290.0120.00316.42
7.3.280.0040.01116.42
7.3.270.0110.00717.40
7.3.260.0160.00618.24
7.3.250.0110.00616.52
7.3.240.0070.01016.49
7.3.230.0150.00316.63
7.3.210.0090.00916.29
7.3.200.0130.01019.39
7.3.190.0060.01316.29
7.3.180.0140.00416.32
7.3.170.0160.00016.50
7.3.160.0100.00716.27
7.3.120.0060.01014.84
7.3.110.0110.00715.07
7.3.100.0000.01414.93
7.3.90.0000.01414.89
7.3.80.0030.00714.79
7.3.70.0030.00714.75
7.3.60.0060.00614.72
7.3.50.0070.00714.60
7.3.40.0030.01015.05
7.3.30.0030.00714.62
7.3.20.0030.01216.92
7.3.10.0070.00716.68
7.3.00.0110.00416.64
7.2.330.0030.01516.51
7.2.320.0060.01216.78
7.2.310.0140.00416.75
7.2.300.0140.01016.60
7.2.290.0120.00616.75
7.2.250.0130.00714.79
7.2.240.0060.01215.11
7.2.230.0040.00814.91
7.2.220.0030.00615.14
7.2.210.0070.00714.89
7.2.200.0070.00715.15
7.2.190.0030.00914.96
7.2.180.0100.00015.24
7.2.170.0000.01415.15
7.2.60.0120.00316.91
7.2.00.0110.00019.09
7.1.330.0000.01415.68
7.1.320.0040.01215.85
7.1.310.0000.01515.72
7.1.300.0040.00415.64
7.1.290.0030.00915.86
7.1.280.0130.00015.84
7.1.270.0000.01115.56
7.1.260.0030.00715.98
7.1.200.0060.00315.86
7.1.100.0030.00618.09
7.1.70.0000.01617.25
7.1.60.0040.01517.23
7.1.50.0040.00816.70
7.1.40.0030.01016.68
7.1.30.0030.01716.52
7.1.20.0030.01016.77
7.1.10.0040.01416.55
7.1.00.0050.00516.67
7.0.200.0030.01016.82
7.0.190.0040.00416.83
7.0.180.0060.00316.30
7.0.170.0050.00516.25
7.0.160.0000.01016.57
7.0.150.0030.01516.25
7.0.140.0040.00416.46
7.0.130.0000.01716.76
7.0.120.0040.01216.68
7.0.110.0000.01016.46
7.0.100.0070.01316.41
7.0.90.0000.01516.26
7.0.80.0000.01116.53
7.0.70.0040.00716.54
7.0.60.0030.01016.28
7.0.50.0040.00416.48
7.0.40.0000.01415.54
7.0.30.0030.01215.54
7.0.20.0000.00815.54
7.0.10.0030.00615.54
7.0.00.0030.00615.54
5.6.300.0160.05820.90
5.6.290.0070.04020.66
5.6.280.0060.03820.77
5.6.270.0030.07120.85
5.6.260.0030.04420.91
5.6.250.0030.06220.82
5.6.240.0070.06120.82
5.6.230.0130.04220.92
5.6.220.0070.05420.79
5.6.210.0130.07920.64
5.6.200.0030.05620.99
5.6.190.0000.06321.02
5.6.180.0030.04820.78
5.6.170.0130.03520.99
5.6.160.0130.07420.96
5.6.150.0070.08120.87
5.6.140.0030.07320.77
5.6.130.0070.04021.03
5.6.120.0030.09120.99
5.6.110.0070.07720.82
5.6.100.0160.04920.97
5.6.90.0060.03820.95
5.6.80.0030.05120.21
5.6.70.0030.04520.20
5.6.60.0100.03920.30
5.6.50.0000.04420.21
5.6.40.0070.03520.19
5.6.30.0000.04120.18
5.6.20.0060.03520.41
5.6.10.0030.03820.38
5.6.00.0060.03520.09
5.5.380.0030.07217.57
5.5.370.0030.08217.45
5.5.360.0130.06817.52
5.5.350.0070.05917.51
5.5.340.0030.04117.71
5.5.330.0030.04618.01
5.5.320.0060.08418.18
5.5.310.0030.05218.06
5.5.300.0030.04618.09
5.5.290.0000.06217.74
5.5.280.0100.08518.11
5.5.270.0070.07018.02
5.5.260.0070.05118.05
5.5.250.0030.07817.67
5.5.240.0030.04217.56
5.5.230.0100.03517.55
5.5.220.0060.03517.38
5.5.210.0000.04317.08
5.5.200.0060.03517.39
5.5.190.0160.03217.44
5.5.180.0070.04217.45
5.5.160.0000.04217.44
5.5.150.0030.03617.05
5.5.140.0100.05917.49
5.5.130.0060.03517.05
5.5.120.0070.03717.09
5.5.110.0030.04117.48
5.5.100.0070.04016.97
5.5.90.0060.03216.99
5.5.80.0100.03016.96
5.5.70.0000.04517.33
5.5.60.0100.03516.95
5.5.50.0030.03617.11
5.5.40.0000.04516.95
5.5.30.0030.03917.26
5.5.20.0030.04117.26
5.5.10.0040.03617.32
5.5.00.0100.03517.36
5.4.450.0030.07619.43
5.4.440.0070.07619.56
5.4.430.0100.06619.38
5.4.420.0040.04619.45
5.4.410.0000.05019.18
5.4.400.0030.06318.99
5.4.390.0070.05018.90
5.4.380.0060.03519.09
5.4.370.0030.04018.94
5.4.360.0090.03519.07
5.4.350.0160.02819.11
5.4.340.0030.03719.07
5.4.320.0070.03619.21
5.4.310.0130.03218.99
5.4.300.0030.04219.20
5.4.290.0000.04319.06
5.4.280.0190.02918.98
5.4.270.0040.03919.24
5.4.260.0030.04019.08
5.4.250.0030.03518.92
5.4.240.0030.05119.15
5.4.230.0000.04018.98
5.4.220.0030.04318.89
5.4.210.0030.03818.94
5.4.200.0030.03618.98
5.4.190.0000.04419.20
5.4.180.0000.04218.94
5.4.170.0030.03818.98
5.4.160.0030.03619.07
5.4.150.0070.03719.19
5.4.140.0100.03616.51
5.4.130.0000.04116.77
5.4.120.0030.04116.45
5.4.110.0130.03016.76
5.4.100.0070.03416.64
5.4.90.0040.03516.73
5.4.80.0000.03816.73
5.4.70.0030.03416.47
5.4.60.0030.03316.68
5.4.50.0090.03216.44
5.4.40.0170.03116.45
5.4.30.0040.03516.71
5.4.20.0060.03216.71
5.4.10.0030.03416.71
5.4.00.0030.03416.17
5.3.290.0030.03615.54
5.3.280.0070.03615.54
5.3.270.0030.04115.54
5.3.260.0100.03215.54
5.3.250.0030.03915.54
5.3.240.0000.04115.54
5.3.230.0000.04115.54
5.3.220.0000.03815.54
5.3.210.0100.03515.54
5.3.200.0000.04015.54
5.3.190.0030.03815.54
5.3.180.0000.04315.54
5.3.170.0000.04015.54
5.3.160.0000.04115.54
5.3.150.0030.03615.54
5.3.140.0030.03615.54
5.3.130.0060.03615.54
5.3.120.0030.04015.54
5.3.110.0060.04115.54
5.3.100.0030.03615.54
5.3.90.0060.03115.54
5.3.80.0030.03615.54
5.3.70.0000.03815.54
5.3.60.0070.04115.54
5.3.50.0030.03315.54
5.3.40.0070.03315.54
5.3.30.0000.04715.54
5.3.20.0030.03915.54
5.3.10.0070.05415.54
5.3.00.0000.04915.54
5.2.170.0000.03415.54
5.2.160.0070.05815.54
5.2.150.0030.02915.54
5.2.140.0040.03515.54
5.2.130.0070.05015.54
5.2.120.0000.04615.54
5.2.110.0000.04015.54
5.2.100.0070.04715.54
5.2.90.0070.03615.54
5.2.80.0000.03315.54
5.2.70.0000.03415.54
5.2.60.0000.06215.54
5.2.50.0070.05315.54
5.2.40.0030.03315.54
5.2.30.0030.04915.54
5.2.20.0060.02615.54
5.2.10.0030.04015.54
5.2.00.0030.05615.54
5.1.60.0070.03015.54
5.1.50.0030.04215.54
5.1.40.0030.02515.54
5.1.30.0100.04115.54
5.1.20.0030.03715.54
5.1.10.0000.05215.54
5.1.00.0070.05615.54
5.0.50.0070.01715.54
5.0.40.0160.01615.54
5.0.30.0000.04115.54
5.0.20.0030.02115.54
5.0.10.0070.04615.54
5.0.00.0030.05115.54
4.4.90.0030.01515.54
4.4.80.0030.01415.54
4.4.70.0030.01515.54
4.4.60.0030.01315.54
4.4.50.0000.03015.54
4.4.40.0000.02915.54
4.4.30.0030.01615.54
4.4.20.0130.02215.54
4.4.10.0100.01015.54
4.4.00.0030.03215.54
4.3.110.0000.01915.54
4.3.100.0000.01915.54
4.3.90.0040.01815.54
4.3.80.0030.02315.54
4.3.70.0000.01715.54
4.3.60.0030.01515.54
4.3.50.0030.01515.54
4.3.40.0030.02415.54
4.3.30.0030.01515.54
4.3.20.0070.03415.54
4.3.10.0030.03415.54
4.3.00.0000.02215.54

preferences:
44.58 ms | 401 KiB | 5 Q