3v4l.org

run code in 300+ PHP versions simultaneously
<?php function build(){ $items = [ 1=>['categories_id'=>1,'name'=>'父1','parent_id'=>0], 9=>['categories_id'=>9,'name'=>'儿3-1','parent_id'=>3], 15=>['categories_id'=>15,'name'=>'儿3-1-1','parent_id'=>14], 3=>['categories_id'=>3,'name'=>'父3','parent_id'=>0], 4=>['categories_id'=>4,'name'=>'儿1-1','parent_id'=>1], 6=>['categories_id'=>6,'name'=>'儿1-3','parent_id'=>1], 12=>['categories_id'=>12,'name'=>'儿2-1-1','parent_id'=>7], 2=>['categories_id'=>2,'name'=>'父2','parent_id'=>0], 5=>['categories_id'=>5,'name'=>'儿1-2','parent_id'=>1], 8=>['categories_id'=>8,'name'=>'儿2-1','parent_id'=>2], 11=>['categories_id'=>11,'name'=>'儿1-1-1','parent_id'=>4], 7=>['categories_id'=>7,'name'=>'儿2-1','parent_id'=>2], 10=>['categories_id'=>10,'name'=>'儿3-1-1','parent_id'=>9], 13=>['categories_id'=>13,'name'=>'儿3-1-1','parent_id'=>10], 14=>['categories_id'=>14,'name'=>'儿3-1-1','parent_id'=>13], 16=>['categories_id'=>16,'name'=>'儿3-1-1','parent_id'=>10], ]; $tree = array(); foreach($items as $cid => $item){ if(isset($items[$item['parent_id']])){ // var_dump($tree); $items[$item['parent_id']]['childs'][$cid] = &$items[$cid]; }else{ $tree[$cid] = &$items[$cid]; } } return $tree; } $tree = build(); // print_r($tree); foreach ($tree as $cid => $item) { var_dump($item); }

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.0190.00318.68
8.3.60.0100.01016.50
8.3.50.0090.00616.34
8.3.40.0110.00619.02
8.3.30.0090.00918.59
8.3.20.0040.00419.09
8.3.10.0050.00518.82
8.3.00.0090.00019.80
8.2.180.0130.00318.29
8.2.170.0090.00922.96
8.2.160.0120.00320.77
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0080.00019.83
8.2.120.0000.00826.35
8.2.110.0040.00420.35
8.2.100.0040.00817.78
8.2.90.0080.00017.63
8.2.80.0060.00318.73
8.2.70.0050.00317.93
8.2.60.0030.00618.05
8.2.50.0000.00818.10
8.2.40.0080.00021.20
8.2.30.0040.00419.51
8.2.20.0000.00818.14
8.2.10.0040.00418.05
8.2.00.0040.00419.57
8.1.280.0110.00825.92
8.1.270.0060.00323.82
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0070.00323.90
8.1.230.0080.00420.95
8.1.220.0040.00418.36
8.1.210.0030.00618.77
8.1.200.0030.00617.35
8.1.190.0040.00417.10
8.1.180.0040.00418.10
8.1.170.0030.00618.56
8.1.160.0040.00420.67
8.1.150.0070.00018.92
8.1.140.0040.00417.78
8.1.130.0000.00718.96
8.1.120.0000.00717.45
8.1.110.0030.00617.36
8.1.100.0000.00817.51
8.1.90.0040.00417.45
8.1.80.0050.00317.37
8.1.70.0000.00817.48
8.1.60.0000.01017.65
8.1.50.0060.00317.54
8.1.40.0000.00917.59
8.1.30.0100.00017.67
8.1.20.0000.00817.72
8.1.10.0000.00717.59
8.1.00.0040.00417.39
8.0.300.0000.00918.77
8.0.290.0060.00317.18
8.0.280.0040.00418.38
8.0.270.0040.00417.19
8.0.260.0000.01017.19
8.0.250.0070.00316.94
8.0.240.0030.00316.84
8.0.230.0040.00416.99
8.0.220.0040.00416.78
8.0.210.0040.00416.89
8.0.200.0030.00316.90
8.0.190.0030.00616.86
8.0.180.0030.00516.96
8.0.170.0080.00316.91
8.0.160.0000.00816.91
8.0.150.0070.00416.79
8.0.140.0040.00416.86
8.0.130.0060.00013.29
8.0.120.0040.00416.89
8.0.110.0000.00716.86
8.0.100.0000.00716.98
8.0.90.0040.00416.74
8.0.80.0120.00916.91
8.0.70.0000.00716.75
8.0.60.0030.00516.78
8.0.50.0000.00716.81
8.0.30.0100.00917.06
8.0.20.0150.00617.40
8.0.10.0040.00417.10
8.0.00.0150.00516.75
7.4.330.0000.00515.55
7.4.320.0070.00016.53
7.4.300.0000.00716.52
7.4.290.0000.00716.52
7.4.280.0060.00316.57
7.4.270.0000.00716.64
7.4.260.0000.00716.53
7.4.250.0070.00016.48
7.4.240.0000.00716.54
7.4.230.0030.00416.71
7.4.220.0000.00716.42
7.4.210.0070.00916.61
7.4.200.0000.00716.43
7.4.160.0070.01316.44
7.4.140.0130.01017.86
7.4.130.0070.01916.55
7.4.120.0130.00916.55
7.4.110.0160.00816.44
7.4.100.0070.01116.58
7.4.90.0090.00916.39
7.4.80.0160.00919.39
7.4.70.0100.00716.30
7.4.60.0100.01016.38
7.4.50.0070.00416.48
7.4.40.0040.01416.61
7.4.00.0100.00915.02
7.3.330.0000.00513.23
7.3.320.0000.00613.28
7.3.310.0000.00716.35
7.3.300.0030.00316.20
7.3.290.0040.00416.21
7.3.280.0110.01016.38
7.3.260.0150.00716.38
7.3.240.0110.01016.44
7.3.230.0130.01316.61
7.3.210.0060.01416.45
7.3.200.0120.00616.62
7.3.190.0100.01016.22
7.3.180.0090.01316.59
7.3.170.0100.01316.49
7.3.160.0140.01016.40
7.3.120.0070.01314.80
7.3.110.0100.00714.70
7.3.100.0110.00514.68
7.3.90.0030.01014.81
7.3.80.0070.00614.92
7.3.70.0080.00614.81
7.3.60.0050.00814.85
7.3.50.0040.00814.79
7.3.40.0070.00514.71
7.3.30.0040.00814.79
7.3.20.0060.01016.70
7.3.10.0030.01316.57
7.3.00.0080.00716.55
7.2.330.0130.00716.72
7.2.320.0110.00816.38
7.2.310.0120.00816.48
7.2.300.0070.01116.80
7.2.290.0090.00916.56
7.2.250.0070.01315.29
7.2.240.0110.00814.92
7.2.230.0040.01315.09
7.2.220.0060.00714.96
7.2.210.0050.00815.20
7.2.200.0040.00814.99
7.2.190.0090.00514.99
7.2.180.0050.00615.12
7.2.170.0040.01115.11
7.2.130.0090.00616.93
7.2.120.0040.00817.08
7.2.110.0060.00916.91
7.2.100.0040.01416.97
7.2.90.0000.01316.84
7.2.80.0090.00617.00
7.2.70.0120.00616.99
7.2.60.1730.01015.64
7.2.50.1610.00715.60
7.2.40.1880.00815.96
7.2.30.1700.01015.88
7.2.20.1580.01115.77
7.2.10.1820.00916.00
7.2.00.1660.00815.95
7.1.330.0060.00915.82
7.1.320.0050.00815.85
7.1.310.0050.00815.77
7.1.300.0050.00815.89
7.1.290.0070.00515.77
7.1.280.0050.01115.89
7.1.270.0060.00715.76
7.1.260.0050.01015.85
7.1.250.0080.00815.75
7.1.200.0030.01016.01
7.1.170.2540.01114.01
7.1.160.2470.01316.66
7.1.150.2600.01116.96
7.1.140.2600.01116.91
7.1.130.2340.00816.69
7.1.120.2440.01116.80
7.1.110.2660.01116.32
7.1.100.2760.01415.91
7.1.90.3440.01216.06
7.1.80.2930.01115.95
7.1.70.3350.01115.27
7.1.60.3340.01333.29
7.1.50.4000.01232.97
7.1.40.4210.01532.79
7.1.30.4200.01332.64
7.1.20.4550.01732.65
7.1.10.3850.01314.72
7.1.00.3050.01414.76

preferences:
50.19 ms | 400 KiB | 5 Q