3v4l.org

run code in 300+ PHP versions simultaneously
<?php $categories = array( array( 'parent_id' => 0, 'categories_id' => 1, ), array( 'parent_id' => 0, 'categories_id' => 2, ), array( 'parent_id' => 1, 'categories_id' => 11, ), array( 'parent_id' => 1, 'categories_id' => 111, ), array( 'parent_id' => 2, 'categories_id' => 22, ), ); $tree = array(); foreach ($categories as $category) { $tree = &build($category, $tree); } // var_export($tree); function &build($category, &$tree = array()) { if ($category['parent_id'] == 0) { $category = array( $category['categories_id'] => $category, ); $tree = array_merge($tree, $category); return $tree; } foreach ($tree as $cate_id => $cate) { var_dump($tree); if ($category['parent_id'] == $cate_id) { $tree[$cate_id]['childs'] = $category; } if (is_array($cate)) { return build($cate, $tree); } } 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.3.60.0120.00318.30
8.3.50.0100.00716.34
8.3.40.0120.00918.75
8.3.30.0100.00618.63
8.3.20.0040.00419.14
8.3.10.0060.00319.02
8.3.00.0040.00419.56
8.2.180.0070.01516.75
8.2.170.0060.00922.96
8.2.160.0110.00320.67
8.2.150.0050.00324.18
8.2.140.0000.00824.66
8.2.130.0080.00019.60
8.2.120.0000.00826.35
8.2.110.0090.00020.44
8.2.100.0060.00618.03
8.2.90.0000.00817.48
8.2.80.0060.00318.93
8.2.70.0090.00017.80
8.2.60.0000.00818.16
8.2.50.0000.00818.10
8.2.40.0000.00819.53
8.2.30.0000.00719.43
8.2.20.0040.00418.14
8.2.10.0040.00418.04
8.2.00.0070.00019.38
8.1.280.0120.00325.92
8.1.270.0070.00023.84
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0060.00322.02
8.1.230.0060.00621.04
8.1.220.0080.00018.42
8.1.210.0030.00618.77
8.1.200.0050.00317.48
8.1.190.0040.00417.35
8.1.180.0050.00318.10
8.1.170.0050.00318.50
8.1.160.0040.00420.68
8.1.150.0070.00018.92
8.1.140.0040.00417.66
8.1.130.0040.00419.06
8.1.120.0040.00417.44
8.1.110.0030.00417.43
8.1.100.0040.00717.32
8.1.90.0040.00417.48
8.1.80.0060.00317.47
8.1.70.0050.00217.48
8.1.60.0090.00017.59
8.1.50.0040.00417.50
8.1.40.0050.00217.53
8.1.30.0030.00517.67
8.1.20.0060.00317.59
8.1.10.0040.00417.46
8.1.00.0000.00817.46
8.0.300.0070.00018.77
8.0.290.0050.00216.58
8.0.280.0000.00718.32
8.0.270.0030.00317.30
8.0.260.0030.00319.06
8.0.250.0070.00017.00
8.0.240.0030.00616.96
8.0.230.0030.00316.87
8.0.220.0000.00816.88
8.0.210.0000.00716.91
8.0.200.0000.00616.97
8.0.190.0030.00516.87
8.0.180.0040.00416.95
8.0.170.0060.00316.94
8.0.160.0000.00816.94
8.0.150.0000.00716.73
8.0.140.0050.00316.75
8.0.130.0060.00313.39
8.0.120.0030.00616.75
8.0.110.0040.00416.86
8.0.100.0040.00416.79
8.0.90.0080.00016.69
8.0.80.0060.00916.85
8.0.70.0000.00816.84
8.0.60.0000.00716.93
8.0.50.0070.00016.88
8.0.30.0060.01517.10
8.0.20.0130.01017.40
8.0.10.0000.00716.96
8.0.00.0080.01016.75
7.4.330.0050.00015.55
7.4.320.0000.00616.51
7.4.300.0000.00616.50
7.4.290.0000.00716.52
7.4.280.0080.00016.61
7.4.270.0040.00416.46
7.4.260.0070.00016.57
7.4.250.0070.00016.49
7.4.240.0040.00416.61
7.4.230.0070.00016.68
7.4.220.0000.00816.30
7.4.210.0080.01116.60
7.4.200.0030.00316.69
7.4.160.0120.00516.46
7.4.140.0100.01017.86
7.4.130.0100.01016.54
7.4.120.0130.00816.53
7.4.110.0100.00716.41
7.4.100.0060.01216.51
7.4.90.0140.00616.44
7.4.80.0090.01219.39
7.4.70.0110.01216.57
7.4.60.0140.00616.60
7.4.50.0060.01016.65
7.4.40.0120.00516.52
7.4.00.0070.01114.75
7.3.330.0000.00513.30
7.3.320.0000.00613.20
7.3.310.0050.00316.27
7.3.300.0070.00016.23
7.3.290.0000.00716.41
7.3.280.0090.00616.39
7.3.260.0100.01116.51
7.3.240.0090.01216.53
7.3.230.0110.00716.48
7.3.210.0120.00616.71
7.3.200.0100.00716.59
7.3.190.0180.00016.42
7.3.180.0130.00316.37
7.3.170.0070.01516.65
7.3.160.0060.01216.51
7.3.10.0130.00016.77
7.3.00.0120.00316.73
7.2.330.0130.01316.79
7.2.320.0090.01316.65
7.2.310.0100.01016.81
7.2.300.0090.00916.50
7.2.290.0150.00616.77
7.2.130.0040.00916.92
7.2.120.0100.00216.81
7.2.110.0050.00917.06
7.2.100.0070.00616.78
7.2.90.0110.00317.02
7.2.80.0040.01116.95
7.2.70.0070.00917.09
7.2.60.2540.00816.25
7.2.50.2850.00716.25
7.2.40.2530.01116.38
7.2.30.2700.00916.46
7.2.20.2520.01016.16
7.2.10.2810.00916.40
7.2.00.2720.00916.48
7.1.250.0050.00915.64
7.1.240.0030.01315.84
7.1.230.0080.00415.75
7.1.220.0040.01115.98
7.1.210.0030.00715.88
7.1.200.0080.00615.83
7.1.190.0160.00015.86
7.1.180.0120.00415.63
7.1.170.4120.00814.88
7.1.160.4140.00816.37
7.1.150.4230.00916.22
7.1.140.4360.01016.08
7.1.130.3470.00616.33
7.1.120.4190.01116.18
7.1.110.3690.00716.11
7.1.100.3800.00815.97
7.1.90.4710.00615.83
7.1.80.3350.00916.01
7.1.70.4580.00515.68
7.1.60.3900.00724.40
7.1.50.5110.01224.43
7.1.40.5550.01224.13
7.1.30.5430.01024.23
7.1.20.6620.01024.19
7.1.10.0080.01015.07
7.1.00.5760.01015.19
7.0.330.0030.01315.44
5.6.380.0030.00614.61

preferences:
57.11 ms | 401 KiB | 5 Q