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, ), ); foreach ($categories as $category) { } 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) { 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.70.0090.00616.63
8.3.60.0120.00318.18
8.3.50.0000.01516.48
8.3.40.0150.00718.67
8.3.30.0120.00318.54
8.3.20.0040.00418.99
8.3.10.0040.00420.89
8.3.00.0000.00817.68
8.2.180.0210.00016.38
8.2.170.0120.00318.95
8.2.160.0030.01022.96
8.2.150.0060.00325.66
8.2.140.0070.00024.66
8.2.130.0050.00319.95
8.2.120.0050.00326.35
8.2.110.0030.00622.25
8.2.100.0030.01217.78
8.2.90.0080.00017.75
8.2.80.0000.00818.78
8.2.70.0080.00017.50
8.2.60.0040.00417.63
8.2.50.0000.00817.80
8.2.40.0000.00819.48
8.2.30.0040.00419.44
8.2.20.0060.00318.06
8.2.10.0070.00017.94
8.2.00.0000.00719.37
8.1.280.0070.01325.92
8.1.270.0070.00023.91
8.1.260.0070.00026.35
8.1.250.0030.00628.09
8.1.240.0060.00323.79
8.1.230.0070.00419.15
8.1.220.0000.00717.74
8.1.210.0080.00018.77
8.1.200.0030.00517.23
8.1.190.0040.00417.35
8.1.180.0000.00818.10
8.1.170.0050.00317.62
8.1.160.0050.00320.71
8.1.150.0050.00218.82
8.1.140.0000.01117.70
8.1.130.0000.01019.01
8.1.120.0030.00617.46
8.1.110.0000.00717.29
8.1.100.0030.00617.49
8.1.90.0080.00017.46
8.1.80.0050.00317.32
8.1.70.0040.00417.46
8.1.60.0000.00817.57
8.1.50.0040.00417.50
8.1.40.0050.00317.52
8.1.30.0000.00817.59
8.1.20.0000.00717.73
8.1.10.0000.00717.36
8.1.00.0000.00917.41
8.0.300.0000.00718.77
8.0.290.0030.00516.75
8.0.280.0000.00818.49
8.0.270.0000.00717.26
8.0.260.0030.00318.92
8.0.250.0000.00716.98
8.0.240.0050.00516.87
8.0.230.0030.00317.01
8.0.220.0040.00416.91
8.0.210.0000.00716.80
8.0.200.0000.00716.94
8.0.190.0000.00716.96
8.0.180.0040.00417.00
8.0.170.0060.00316.97
8.0.160.0000.00916.93
8.0.150.0030.00416.86
8.0.140.0040.00316.75
8.0.130.0000.00713.38
8.0.120.0030.00616.90
8.0.110.0000.00716.81
8.0.100.0000.00716.76
8.0.90.0030.00516.72
8.0.80.0090.00516.87
8.0.70.0040.00416.95
8.0.60.0000.00816.95
8.0.50.0040.00416.77
8.0.30.0090.00917.00
8.0.20.0110.00817.40
8.0.10.0040.00417.00
8.0.00.0140.00416.90
7.4.330.0020.00215.55
7.4.320.0000.00616.52
7.4.300.0030.00316.60
7.4.290.0030.00316.49
7.4.280.0040.00316.59
7.4.270.0030.00316.59
7.4.260.0070.00016.48
7.4.250.0030.00316.44
7.4.240.0000.00716.47
7.4.230.0030.00316.48
7.4.220.0000.00816.60
7.4.210.0050.01016.57
7.4.200.0070.00016.40
7.4.160.0080.00716.47
7.4.140.0100.00917.86
7.4.130.0150.00316.38
7.4.120.0120.00916.54
7.4.110.0130.02616.48
7.4.100.0170.00016.44
7.4.90.0060.01216.60
7.4.80.0140.00419.39
7.4.70.0030.01316.50
7.4.60.0090.00916.33
7.4.50.0070.00716.67
7.4.40.0150.00816.42
7.4.00.0040.01214.96
7.3.330.0020.00213.13
7.3.320.0030.00313.26
7.3.310.0000.00716.39
7.3.300.0030.00316.15
7.3.290.0070.00016.16
7.3.280.0090.00916.30
7.3.260.0100.00916.44
7.3.240.0090.00916.38
7.3.230.0070.01016.57
7.3.210.0040.01416.41
7.3.200.0070.01016.66
7.3.190.0090.00616.38
7.3.180.0120.00316.38
7.3.170.0120.00916.36
7.3.160.0100.00716.63
7.3.120.0100.00314.56
7.3.110.0060.00914.92
7.3.100.0060.00314.96
7.3.90.0000.01114.87
7.3.80.0030.00814.71
7.3.70.0060.00614.79
7.3.60.0000.01014.89
7.3.50.0060.00314.94
7.3.40.0060.00614.86
7.3.30.0080.00314.88
7.3.20.0070.00716.69
7.3.10.0050.00516.67
7.3.00.0070.00416.50
7.2.330.0070.01116.53
7.2.320.0130.00616.71
7.2.310.0070.01016.47
7.2.300.0130.00316.50
7.2.290.0110.00816.61
7.2.250.0110.00314.90
7.2.240.0040.01514.86
7.2.230.0070.00715.20
7.2.220.0100.00314.91
7.2.210.0000.01215.14
7.2.200.0070.00315.04
7.2.190.0000.01414.86
7.2.180.0060.00615.11
7.2.170.0000.01114.86
7.2.60.3170.01214.94
7.2.50.3410.00814.78
7.2.40.3940.01015.23
7.2.30.3720.01115.24
7.2.20.4180.00815.40
7.2.10.3170.00815.23
7.2.00.4650.01015.30
7.1.330.0120.00315.41
7.1.320.0030.00715.63
7.1.310.0060.00615.64
7.1.300.0000.00915.66
7.1.290.0070.00315.54
7.1.280.0080.00615.72
7.1.270.0090.00615.39
7.1.260.0060.00915.77
7.1.200.0080.00415.66
7.1.170.3680.00913.66
7.1.160.4170.01116.90
7.1.150.4280.01316.63
7.1.140.2640.01216.52
7.1.130.3010.01016.51
7.1.120.3000.00916.72
7.1.110.2700.01015.99
7.1.100.2980.01416.23
7.1.90.3680.01416.11
7.1.80.4790.01416.21
7.1.70.4410.00715.17
7.1.60.2980.00932.89
7.1.50.3900.01432.88
7.1.40.5710.02032.53
7.1.30.4770.02032.51
7.1.20.4710.01632.54
7.1.10.6010.01214.54
7.1.00.4560.01114.76

preferences:
54.43 ms | 401 KiB | 5 Q