3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ 1=>['id'=>1,'name'=>'父1','father'=>NULL], 2=>['id'=>2,'name'=>'父2','father'=>NULL], 3=>['id'=>3,'name'=>'父3','father'=>NULL], 4=>['id'=>4,'name'=>'儿1-1','father'=>1], 5=>['id'=>5,'name'=>'儿1-2','father'=>1], 6=>['id'=>6,'name'=>'儿1-3','father'=>1], 7=>['id'=>7,'name'=>'儿2-1','father'=>2], 8=>['id'=>8,'name'=>'儿2-1','father'=>2], 9=>['id'=>9,'name'=>'儿3-1','father'=>3], 10=>['id'=>10,'name'=>'儿3-1-1','father'=>9], 11=>['id'=>11,'name'=>'儿1-1-1','father'=>4], 12=>['id'=>12,'name'=>'儿2-1-1','father'=>7], ]; function generateTree($items){ $tree = array(); foreach($items as $item){ if(isset($items[$item['father']])){ $items[$item['father']]['son'][$item['id']] = &$items[$item['id']]; }else{ $tree[] = &$items[$item['id']]; } } return $tree; } $tree = generateTree($arr); print_r($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.0090.00918.17
8.3.50.0090.00616.35
8.3.40.0070.00718.57
8.3.30.0110.00718.75
8.3.20.0040.00419.19
8.3.10.0080.00020.91
8.3.00.0050.00317.93
8.2.180.0170.00318.54
8.2.170.0060.00922.96
8.2.160.0070.00720.77
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0060.00319.83
8.2.120.0070.00026.35
8.2.110.0000.01021.04
8.2.100.0060.00617.84
8.2.90.0080.00017.88
8.2.80.0080.00018.73
8.2.70.0080.00018.05
8.2.60.0000.00917.93
8.2.50.0000.00818.10
8.2.40.0000.00821.08
8.2.30.0040.00419.52
8.2.20.0040.00418.01
8.2.10.0050.00318.14
8.2.00.0000.00819.46
8.1.280.0130.00625.92
8.1.270.0080.00024.01
8.1.260.0040.00426.35
8.1.250.0030.00528.09
8.1.240.0070.00321.84
8.1.230.0100.00020.88
8.1.220.0060.00318.48
8.1.210.0040.00418.77
8.1.200.0040.00417.22
8.1.190.0040.00417.25
8.1.180.0040.00418.10
8.1.170.0040.00418.51
8.1.160.0050.00318.86
8.1.150.0000.00718.95
8.1.140.0040.00817.62
8.1.130.0000.00719.28
8.1.120.0090.00017.38
8.1.110.0040.00417.37
8.1.100.0060.00317.37
8.1.90.0040.00417.37
8.1.80.0030.00617.48
8.1.70.0040.00417.38
8.1.60.0050.00317.61
8.1.50.0000.00817.42
8.1.40.0000.00817.57
8.1.30.0100.00017.54
8.1.20.0000.00717.73
8.1.10.0030.00717.62
8.1.00.0030.00617.38
8.0.300.0000.00718.77
8.0.290.0060.00316.75
8.0.280.0000.00718.33
8.0.270.0070.00017.32
8.0.260.0030.00316.75
8.0.250.0070.00017.04
8.0.240.0030.00516.98
8.0.230.0040.00417.03
8.0.220.0040.00416.89
8.0.210.0030.00316.83
8.0.200.0000.00716.86
8.0.190.0040.00416.96
8.0.180.0040.00416.82
8.0.170.0000.00816.93
8.0.160.0000.00716.96
8.0.150.0040.00716.74
8.0.140.0030.00516.86
8.0.130.0000.00613.34
8.0.120.0070.00016.81
8.0.110.0040.00416.73
8.0.100.0070.00016.73
8.0.90.0070.00016.95
8.0.80.0060.01116.95
8.0.70.0050.00316.80
8.0.60.0030.00516.69
8.0.50.0040.00417.02
8.0.30.0100.00717.12
8.0.20.0100.00917.40
8.0.10.0040.00417.05
8.0.00.0070.01216.74
7.4.330.0050.00015.55
7.4.320.0000.00816.63
7.4.300.0000.00616.51
7.4.290.0000.00716.43
7.4.280.0000.00816.51
7.4.270.0060.00616.50
7.4.260.0000.01016.54
7.4.250.0040.00416.60
7.4.240.0040.00416.50
7.4.230.0030.00316.60
7.4.220.0040.00416.64
7.4.210.0070.01116.58
7.4.200.0000.00716.49
7.4.160.0130.00616.49
7.4.140.0140.01317.86
7.4.130.0060.01516.54
7.4.120.0100.00916.57
7.4.110.0130.00416.65
7.4.100.0070.01016.43
7.4.90.0100.00716.51
7.4.80.0030.01419.39
7.4.70.0160.00016.40
7.4.60.0090.01316.56
7.4.50.0030.01216.53
7.4.40.0120.00916.51
7.4.00.0050.00715.02
7.3.330.0000.00513.38
7.3.320.0050.00213.24
7.3.310.0030.00316.38
7.3.300.0030.00316.38
7.3.290.0070.00016.43
7.3.280.0100.01016.40
7.3.260.0090.00916.46
7.3.240.0120.00716.61
7.3.230.0060.01016.57
7.3.210.0090.00916.52
7.3.200.0120.00916.67
7.3.190.0110.00516.47
7.3.180.0100.00716.37
7.3.170.0070.01016.48
7.3.160.0030.01316.42
7.3.120.0030.01214.82
7.3.110.0030.01114.79
7.3.100.0090.00814.84
7.3.90.0070.00614.75
7.3.80.0060.00814.77
7.3.70.0030.00914.78
7.3.60.0060.00714.89
7.3.50.0030.00914.84
7.3.40.0010.01114.77
7.3.30.0070.00814.82
7.3.20.0060.00916.71
7.3.10.0050.01016.71
7.3.00.0080.00616.65
7.2.330.0150.00716.80
7.2.320.0130.00616.78
7.2.310.0070.01016.71
7.2.300.0130.00716.81
7.2.290.0080.01116.79
7.2.250.0060.01215.36
7.2.240.0040.01215.22
7.2.230.0060.00814.91
7.2.220.0050.01115.06
7.2.210.0070.00815.15
7.2.200.0090.00515.07
7.2.190.0070.00815.10
7.2.180.0020.01315.07
7.2.170.0080.00614.90
7.2.160.0090.00715.05
7.2.150.0010.01417.03
7.2.140.0090.00717.03
7.2.130.0040.01116.88
7.2.120.0040.01016.86
7.2.110.0100.00616.95
7.2.100.0070.00616.88
7.2.90.0070.00717.02
7.2.80.0080.00716.97
7.2.70.0050.00917.00
7.2.60.1400.00516.57
7.2.50.1380.00716.48
7.2.40.1420.00716.50
7.2.30.1920.00916.60
7.2.20.1760.00816.72
7.2.10.1500.00816.69
7.2.00.1440.00916.55
7.1.330.0060.00816.03
7.1.320.0050.01215.88
7.1.310.0050.00515.65
7.1.300.0070.00615.74
7.1.290.0090.00315.80
7.1.280.0030.01015.73
7.1.270.0070.00515.91
7.1.260.0050.00915.62
7.1.250.0060.00815.87
7.1.240.0030.00915.86
7.1.230.0090.00015.97
7.1.220.0000.01415.84
7.1.210.0000.01015.55
7.1.200.0120.00215.82
7.1.190.0060.00315.88
7.1.180.0000.01315.71
7.1.170.3140.00514.79
7.1.160.4420.01116.33
7.1.150.4260.00916.21
7.1.140.3850.00616.32
7.1.130.3570.00716.37
7.1.120.3760.00916.48
7.1.110.3450.00716.25
7.1.100.4400.00916.06
7.1.90.9220.00915.87
7.1.80.7450.00815.88
7.1.70.5970.00815.70
7.1.60.6160.00724.34
7.1.50.8710.01524.48
7.1.41.0040.01424.18
7.1.30.9040.00924.14
7.1.20.8290.01024.26
7.1.10.7310.01215.33
7.1.00.4630.00915.17
7.0.330.0110.00415.33
7.0.320.0090.00915.45
7.0.310.0070.00415.42
7.0.300.0000.01415.55
7.0.290.0110.00415.30
7.0.280.0030.01415.59
7.0.270.0130.00315.40
7.0.260.0000.01415.22
7.0.250.0030.01515.39
7.0.240.0070.01115.33
7.0.230.0030.01015.45
7.0.220.0130.00315.43
7.0.210.0030.01315.63
7.0.200.0030.01015.29
7.0.190.0100.01015.32
7.0.180.0060.01315.39
7.0.170.0030.01215.24
7.0.160.0030.01015.35
7.0.150.0130.00315.43
7.0.140.0040.01515.45
7.0.130.0150.00415.58
7.0.120.0040.01415.38
7.0.110.0030.01615.34
7.0.100.0070.01015.49
7.0.90.0090.00615.46
7.0.80.0080.00815.63
7.0.70.0100.01015.65
7.0.60.0190.00315.20
7.0.50.0110.00015.70
7.0.40.0070.01113.55
7.0.30.0110.00813.56
7.0.20.0180.00013.41
7.0.10.0030.01413.21
7.0.00.0030.01013.37
5.6.400.0030.01314.68
5.6.390.0060.01514.64
5.6.380.0090.00914.77
5.6.370.0110.00714.54
5.6.360.0070.00714.67
5.6.350.0090.00613.96
5.6.340.0060.01214.86
5.6.330.0100.00314.02
5.6.320.0100.00714.82
5.6.310.0040.01214.28
5.6.300.0120.00314.20
5.6.290.0040.01514.29
5.6.280.0070.01414.40
5.6.270.0070.00414.80
5.6.260.0070.01014.43
5.6.250.0100.00714.40
5.6.240.0110.00314.57
5.6.230.0030.01014.55
5.6.220.0140.00714.33
5.6.210.0090.00314.52
5.6.200.0060.01214.35
5.6.190.0000.02014.47
5.6.180.0070.01014.46
5.6.170.0060.01214.16
5.6.160.0070.01014.32
5.6.150.0040.01414.16
5.6.140.0030.01314.65
5.6.130.0030.01314.26
5.6.120.0070.01114.45
5.6.110.0040.00714.22
5.6.100.0070.01014.54
5.6.90.0070.00714.80
5.6.80.0100.00714.32
5.6.70.0160.00314.09
5.6.60.0110.00714.27
5.6.50.0100.00714.46
5.6.40.0070.00714.11
5.6.30.0080.00414.18
5.6.20.0070.00714.22
5.6.10.0080.00814.22
5.6.00.0030.01014.43

preferences:
66.76 ms | 401 KiB | 5 Q