3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ 0=>['id'=>1,'name'=>'父1','father'=>0], 1=>['id'=>2,'name'=>'父2','father'=>0], 2=>['id'=>3,'name'=>'父3','father'=>0], 3=>['id'=>4,'name'=>'儿1-1','father'=>1], 4=>['id'=>5,'name'=>'儿1-2','father'=>1], 5=>['id'=>6,'name'=>'儿1-3','father'=>1], 6=>['id'=>7,'name'=>'儿2-1','father'=>2], 7=>['id'=>8,'name'=>'儿2-1','father'=>2], 8=>['id'=>9,'name'=>'儿3-1','father'=>3], 9=>['id'=>10,'name'=>'儿3-1-1','father'=>9], 10=>['id'=>11,'name'=>'儿1-1-1','father'=>4], 11=>['id'=>12,'name'=>'儿2-1-1','father'=>7], ]; function generateTree($arr,$id,$step){ static $tree=[]; foreach($arr as $key=>$val) { if($val['father'] == $id) { $flg = str_repeat('└―',$step); $val[$val['id']] = $flg.$val['name']; $tree[$val['id']] = $val; generateTree($arr , $val['id'] ,$step+1); } } return $tree; } $tree = generateTree($arr,0,0); foreach ($tree as $val){ $new[] = $val['name'].'<br>'; } print_r($new);

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.70.0120.00616.63
8.3.60.0130.00716.50
8.3.50.0110.00416.51
8.3.40.0070.00718.90
8.3.30.0110.00418.59
8.3.20.0040.00419.28
8.3.10.0080.00021.03
8.3.00.0050.00319.79
8.2.180.0170.00318.54
8.2.170.0140.00722.96
8.2.160.0120.00320.94
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0030.00519.77
8.2.120.0050.00326.35
8.2.110.0030.00622.02
8.2.100.0000.01417.78
8.2.90.0040.00417.63
8.2.80.0000.00818.72
8.2.70.0030.00518.05
8.2.60.0040.00418.05
8.2.50.0030.00618.10
8.2.40.0040.00421.13
8.2.30.0000.00719.63
8.2.20.0040.00418.21
8.2.10.0040.00418.14
8.2.00.0060.00319.56
8.1.280.0070.01425.92
8.1.270.0040.00423.73
8.1.260.0000.00826.35
8.1.250.0000.00828.09
8.1.240.0080.00023.96
8.1.230.0080.00419.06
8.1.220.0040.00418.68
8.1.210.0000.00818.77
8.1.200.0060.00317.35
8.1.190.0000.00817.13
8.1.180.0040.00418.10
8.1.170.0000.00818.55
8.1.160.0050.00318.88
8.1.150.0000.00818.96
8.1.140.0040.00417.64
8.1.130.0000.00719.00
8.1.120.0000.01117.50
8.1.110.0040.00417.37
8.1.100.0090.00017.46
8.1.90.0000.00717.47
8.1.80.0030.00717.50
8.1.70.0000.00817.39
8.1.60.0040.00417.66
8.1.50.0040.00417.56
8.1.40.0030.00517.53
8.1.30.0030.00617.59
8.1.20.0040.00417.61
8.1.10.0050.00517.49
8.1.00.0000.00717.50
8.0.300.0040.00418.77
8.0.290.0060.00316.75
8.0.280.0000.00718.54
8.0.270.0000.00717.35
8.0.260.0060.00317.30
8.0.250.0050.00217.01
8.0.240.0030.00316.86
8.0.230.0030.00516.99
8.0.220.0040.00416.95
8.0.210.0030.00316.79
8.0.200.0060.00016.85
8.0.190.0000.00717.03
8.0.180.0040.00416.88
8.0.170.0060.00316.95
8.0.160.0000.00716.81
8.0.150.0070.00316.73
8.0.140.0040.00416.81
8.0.130.0030.00313.36
8.0.120.0040.00416.95
8.0.110.0080.00016.86
8.0.100.0050.00216.93
8.0.90.0000.00816.93
8.0.80.0150.00716.86
8.0.70.0030.00516.90
8.0.60.0030.00516.81
8.0.50.0040.00417.01
8.0.30.0080.01317.05
8.0.20.0140.00617.40
8.0.10.0040.00417.02
8.0.00.0060.01116.89
7.4.330.0020.00215.55
7.4.320.0040.00416.52
7.4.300.0000.00616.60
7.4.290.0050.00316.61
7.4.280.0030.00616.52
7.4.270.0090.00016.39
7.4.260.0080.00316.44
7.4.250.0030.00316.50
7.4.240.0040.00416.43
7.4.230.0000.00716.65
7.4.220.0070.00016.66
7.4.210.0070.01016.53
7.4.200.0040.00416.51
7.4.160.0130.01016.58
7.4.140.0120.00717.86
7.4.130.0100.00716.50
7.4.120.0110.00816.52
7.4.110.0070.01016.43
7.4.100.0070.01016.50
7.4.90.0080.01116.54
7.4.80.0040.01419.39
7.4.70.0120.00916.40
7.4.60.0060.01216.56
7.4.50.0140.00316.50
7.4.40.0120.00816.68
7.4.00.0030.01114.90
7.3.330.0000.00513.34
7.3.320.0030.00313.34
7.3.310.0000.00716.38
7.3.300.0030.00316.27
7.3.290.0040.00416.36
7.3.280.0030.01316.28
7.3.260.0120.00816.46
7.3.240.0130.00816.53
7.3.230.0150.00316.43
7.3.210.0080.01016.45
7.3.200.0130.00316.51
7.3.190.0030.01616.44
7.3.180.0090.00616.63
7.3.170.0100.01016.52
7.3.160.0130.01016.39
7.3.120.0080.01014.90
7.3.110.0100.00814.93
7.3.100.0060.00914.86
7.3.90.0030.01314.92
7.3.80.0060.00814.98
7.3.70.0020.01014.84
7.3.60.0020.01014.93
7.3.50.0070.00514.76
7.3.40.0060.00814.95
7.3.30.0070.00914.78
7.3.20.0060.00616.68
7.3.10.0030.01016.65
7.3.00.0010.00916.55
7.2.330.0100.01316.58
7.2.320.0130.00516.48
7.2.310.0000.01616.73
7.2.300.0120.00616.86
7.2.290.0090.00916.78
7.2.250.0100.01014.94
7.2.240.0090.00915.05
7.2.230.0020.01215.18
7.2.220.0090.00515.28
7.2.210.0040.00815.20
7.2.200.0030.01215.15
7.2.190.0050.00914.88
7.2.180.0070.00915.11
7.2.170.0060.00614.99
7.2.160.0040.00815.08
7.2.150.0070.00717.03
7.2.140.0130.00316.95
7.2.130.0030.01017.15
7.2.120.0040.01116.97
7.2.110.0000.01417.10
7.2.100.0110.00716.90
7.2.90.0030.01017.02
7.2.80.0030.00917.04
7.2.70.0060.00917.03
7.2.60.4280.01415.81
7.2.50.3740.01415.81
7.2.40.3280.00716.14
7.2.30.3950.00616.19
7.2.20.4190.00815.91
7.2.10.4430.00516.27
7.2.00.4260.00816.15
7.1.330.0070.00815.70
7.1.320.0080.00515.78
7.1.310.0070.00715.92
7.1.300.0060.00615.71
7.1.290.0100.00415.78
7.1.280.0050.00815.86
7.1.270.0080.00215.81
7.1.260.0070.00215.97
7.1.250.0030.00915.54
7.1.200.0040.01115.70
7.1.170.7270.01113.66
7.1.160.6760.00916.67
7.1.150.7570.01216.55
7.1.140.8710.01916.82
7.1.130.9230.01216.84
7.1.120.8380.01216.57
7.1.110.7630.01316.26
7.1.100.8230.00916.12
7.1.91.1750.01016.05
7.1.81.1160.01516.17
7.1.71.0290.01115.35
7.1.61.0620.01633.36
7.1.51.0200.01433.05
7.1.41.2110.01432.69
7.1.31.0970.01432.64
7.1.20.9380.01532.64
7.1.11.1050.00814.58
7.1.00.8710.01314.89

preferences:
55.29 ms | 401 KiB | 5 Q