3v4l.org

run code in 300+ PHP versions simultaneously
<?php $flat = [ ['id' => 100, 'parent_id' => 0, 'name' => 'root'], ['id' => 101, 'parent_id' => 100, 'name' => 'ch-1'], ['id' => 102, 'parent_id' => 101, 'name' => 'ch-1-1'], ['id' => 103, 'parent_id' => 101, 'name' => 'ch-1-2'], ['id' => 104, 'parent_id' => 101, 'name' => 'ch-1-2'], ['id' => 105, 'parent_id' => 104, 'name' => 'ch-1-2'], ['id' => 106, 'parent_id' => 101, 'name' => 'ch-1-2'], ['id' => 107, 'parent_id' => 101, 'name' => 'ch-1-2'], ]; $new = array(); foreach ($flat as $a){ $new[$a['parent_id']][] = $a; } $tree = createTree($new, array($flat[0])); print_r($tree); function createTree(&$list, $parent){ $tree = array(); foreach ($parent as $k=>$l){ if(isset($list[$l['id']])){ $l['children'] = createTree($list, $list[$l['id']]); } $tree[] = $l; } return $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.5.10.0110.00818.97
8.5.00.0140.00821.76
8.4.150.0010.00114.05
8.4.140.0120.00917.56
8.4.130.0120.00919.55
8.4.120.0060.00422.28
8.4.110.0120.00418.46
8.4.100.0070.01317.66
8.4.90.0150.00618.29
8.4.80.0130.00817.79
8.4.70.0070.01217.75
8.4.60.0100.00918.81
8.4.50.0100.00519.36
8.4.40.0000.02019.23
8.4.30.0080.01120.64
8.4.20.0150.00617.73
8.4.10.0040.00419.39
8.3.280.0120.00818.47
8.3.270.0080.01216.61
8.3.260.0100.00916.60
8.3.250.0090.00918.63
8.3.240.0090.00720.89
8.3.230.0050.00516.55
8.3.220.0110.00817.15
8.3.210.0140.00416.52
8.3.200.0120.00716.54
8.3.190.0080.00917.16
8.3.180.0150.00516.71
8.3.170.0080.01117.41
8.3.160.0070.01118.56
8.3.150.0110.00820.83
8.3.140.0150.00317.09
8.3.130.0030.00618.37
8.3.120.0090.00019.09
8.3.110.0030.00620.94
8.3.100.0150.00024.06
8.3.90.0000.01426.77
8.3.80.0060.00316.50
8.3.70.0140.00316.75
8.3.60.0210.00016.50
8.3.50.0120.00723.70
8.3.40.0100.01018.68
8.3.30.0070.00718.58
8.3.20.0040.00420.68
8.3.10.0100.00020.33
8.3.00.0080.00020.93
8.2.290.0150.00320.55
8.2.280.0080.00118.66
8.2.270.0090.00017.13
8.2.260.0000.00920.31
8.2.250.0090.00018.37
8.2.240.0060.00317.37
8.2.230.0090.00022.58
8.2.220.0030.00637.54
8.2.210.0080.00026.77
8.2.200.0060.00316.50
8.2.190.0150.00716.75
8.2.180.0090.00918.25
8.2.170.0070.00722.96
8.2.160.0100.00320.45
8.2.150.0060.00324.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0030.00519.39
8.2.110.0050.00521.10
8.2.100.0080.00417.69
8.2.90.0080.00019.32
8.2.80.0000.00817.97
8.2.70.0040.00417.63
8.2.60.0050.00318.05
8.2.50.0090.00018.07
8.2.40.0040.00418.29
8.2.30.0030.00518.14
8.2.20.0000.00818.21
8.2.10.0050.00219.32
8.2.00.0070.00019.36
8.1.330.0110.00721.95
8.1.320.0100.01016.10
8.1.310.0080.00317.00
8.1.300.0080.01116.23
8.1.290.0090.00318.88
8.1.280.0140.00425.92
8.1.270.0030.00722.11
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0090.00022.44
8.1.230.0110.00021.04
8.1.220.0000.00817.74
8.1.210.0000.01118.94
8.1.200.0060.00317.48
8.1.190.0040.00417.36
8.1.180.0030.00618.10
8.1.170.0070.00318.49
8.1.160.0000.00718.84
8.1.150.0050.00218.81
8.1.140.0000.00718.81
8.1.130.0030.00317.33
8.1.120.0000.00717.36
8.1.110.0040.00417.45
8.1.100.0000.00917.44
8.1.90.0080.00417.35
8.1.80.0080.00417.45
8.1.70.0070.00317.47
8.1.60.0080.00617.45
8.1.50.0080.00517.44
8.1.40.0090.00417.40
8.1.30.0090.00417.54
8.1.20.0110.00317.55
8.1.10.0100.00417.49
8.1.00.0040.01017.40
8.0.300.0070.00019.88
8.0.290.0050.00316.63
8.0.280.0080.00018.32
8.0.270.0050.00318.05
8.0.260.0030.00316.82
8.0.250.0070.00016.93
8.0.240.0060.00016.90
8.0.230.0070.00616.91
8.0.220.0030.00916.80
8.0.210.0110.00016.86
8.0.200.0080.00516.81
8.0.190.0080.00616.90
8.0.180.0100.00416.93
8.0.170.0110.00316.84
8.0.160.0070.00516.88
8.0.150.0080.00516.75
8.0.140.0070.00516.73
8.0.130.0070.00414.99
8.0.120.0090.00216.88
8.0.110.0040.00816.81
8.0.100.0090.00416.91
8.0.90.0060.00616.75
8.0.80.0060.01016.88
8.0.70.0030.00916.81
8.0.60.0090.00316.72
8.0.50.0080.00516.83
8.0.30.0070.01116.87
8.0.20.0100.01017.12
8.0.10.0160.00317.01
8.0.00.0120.00916.86
7.4.330.0030.00315.55
7.4.320.0030.00316.62
7.4.300.0010.00516.52
7.4.290.0080.00516.46
7.4.280.0090.00516.50
7.4.270.0040.00916.56
7.4.260.0090.00314.88
7.4.250.0070.00616.52
7.4.240.0060.00516.52
7.4.230.0030.00716.44
7.4.220.0050.00516.54
7.4.210.0090.00516.63
7.4.200.0080.00116.44
7.4.190.0080.00516.62
7.4.180.0060.00916.63
7.4.160.0120.00616.56
7.4.150.0080.01116.41
7.4.140.0110.00816.42
7.4.130.0090.01016.48
7.4.120.0110.00616.48
7.4.110.0140.00416.43
7.4.100.0100.00616.52
7.4.90.0070.00916.53
7.4.80.0110.00917.39
7.4.70.0060.01116.55
7.4.60.0070.00916.49
7.4.50.0080.00716.45
7.4.40.0090.01116.41
7.4.30.0110.00416.56
7.4.20.0130.00616.37
7.4.10.0110.00616.50
7.4.00.0120.00616.48
7.3.330.0050.00616.42
7.3.320.0080.00314.72
7.3.310.0050.00816.34
7.3.300.0080.00516.20
7.3.290.0120.00616.35
7.3.280.0080.01016.23
7.3.270.0090.01016.39
7.3.260.0090.00816.33
7.3.250.0170.00316.36
7.3.240.0090.01016.49
7.3.230.0120.00616.33
7.3.220.0130.00816.27
7.3.210.0110.00716.29
7.3.200.0090.00916.32
7.3.190.0100.00816.40
7.3.180.0100.00716.35
7.3.170.0120.00516.37
7.3.160.0110.00616.42
7.3.150.0090.00616.32
7.3.140.0090.00916.21
7.3.130.0110.00616.23
7.3.120.0100.00916.32
7.3.110.0110.00616.32
7.3.100.0090.00716.17
7.3.90.0110.00916.49
7.3.80.0110.00816.26
7.3.70.0090.00716.45
7.3.60.0100.00816.47
7.3.50.0090.00916.47
7.3.40.0130.00516.37
7.3.30.0080.00916.36
7.3.20.0080.01017.13
7.3.10.0110.00717.04
7.3.00.0110.00717.03
7.2.340.0160.00816.43
7.2.330.0170.00516.46
7.2.320.0140.00816.51
7.2.310.0060.01016.43
7.2.300.0150.00616.50
7.2.290.0110.01016.59
7.2.280.0120.00916.45
7.2.270.0160.00716.43
7.2.260.0120.00916.47
7.2.250.0140.00716.45
7.2.240.0100.00916.55
7.2.230.0180.00716.48
7.2.220.0170.00616.54
7.2.210.0130.01016.48
7.2.200.0110.01116.55
7.2.190.0140.00816.56
7.2.180.0130.00716.53
7.2.170.0110.01116.61
7.2.160.0160.00716.59
7.2.150.0140.00917.23
7.2.140.0180.00517.31
7.2.130.0170.00517.28
7.2.120.0170.00717.35
7.2.110.0160.00917.27
7.2.100.0130.01117.29
7.2.90.0100.01417.33
7.2.80.0470.00817.12
7.2.70.0160.00517.31
7.2.60.0150.00717.24
7.2.50.0110.01117.29
7.2.40.0170.00717.23
7.2.30.0170.00917.32
7.2.20.0090.01117.34
7.2.10.0130.00817.34
7.2.00.0150.00717.32

preferences:
146.05 ms | 403 KiB | 5 Q