3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array( [ "name" => "cat1", "id" => "1", "parent" => "", ], [ "name" => "cat2", "id" => "2", "parent" => "", ], [ "name" => "subcat1", "id" => "6", "parent" => "1", ], [ "name" => "subsubcat1", "id" => "7", "parent" => "6", ], [ "name" => "subcat2", "id" => "5", "parent" => "2", ], ); function list_item($arr, $item) { echo "<li>{$item['name']}</li>\n"; // find any children $children = array_filter($arr, function ($i) use ($item) { return $i['parent'] == $item['id']; }); if (!empty($children)) { echo "<ul>\n"; foreach ($children as $child) { list_item($arr, $child); } echo "</ul>\n"; } } $parents = array_filter($arr, function ($item) { return !$item['parent'];}); echo "<ul>\n"; foreach ($parents as $parent) { list_item($arr, $parent); } echo "</ul>\n";

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.140.0120.00316.71
8.3.130.0040.00416.57
8.3.120.0040.01519.04
8.3.110.0000.00816.50
8.3.100.0030.00724.06
8.3.90.0080.00026.77
8.3.80.0060.00316.75
8.3.70.0230.00716.58
8.3.60.0070.01418.55
8.3.50.0150.00624.43
8.3.40.0140.00720.47
8.3.30.0120.00318.72
8.3.20.0040.00421.97
8.3.10.0040.01122.05
8.3.00.0000.00820.58
8.2.250.0040.00416.45
8.2.240.0030.00618.84
8.2.230.0000.00820.94
8.2.220.0000.00937.54
8.2.210.0030.00726.77
8.2.200.0000.00918.54
8.2.190.0070.01016.75
8.2.180.0040.01118.29
8.2.170.0130.00622.96
8.2.160.0070.00719.27
8.2.150.0040.00424.18
8.2.140.0090.00924.66
8.2.130.0070.00026.16
8.2.120.0080.00026.16
8.2.110.0030.00619.41
8.2.100.0120.00017.84
8.2.90.0000.00817.88
8.2.80.0090.00018.91
8.2.70.0040.00417.80
8.2.60.0080.00018.16
8.2.50.0050.00219.38
8.2.40.0040.00421.24
8.2.30.0030.00519.45
8.2.20.0050.00318.06
8.2.10.0030.00619.38
8.2.00.0040.00419.31
8.1.300.0030.00618.08
8.1.290.0090.00030.84
8.1.280.0070.00725.92
8.1.270.0040.00422.05
8.1.260.0000.00826.35
8.1.250.0060.00328.09
8.1.240.0060.00323.95
8.1.230.0070.00424.03
8.1.220.0040.00417.79
8.1.210.0040.00418.77
8.1.200.0040.00417.36
8.1.190.0080.00017.35
8.1.180.0040.00418.95
8.1.170.0000.00818.61
8.1.160.0000.01118.98
8.1.150.0020.00518.77
8.1.140.0020.00518.87
8.1.130.0030.00520.14
8.1.120.0040.00417.49
8.1.110.0030.00417.50
8.1.100.0000.00717.39
8.1.90.0070.00017.35
8.1.80.0040.00417.35
8.1.70.0040.00417.38
8.1.60.0090.00017.52
8.1.50.0030.00517.56
8.1.40.0080.00017.45
8.1.30.0080.00017.66
8.1.20.0060.00317.49
8.1.10.0030.00617.57
8.1.00.0040.00417.42
8.0.300.0000.00818.77
8.0.290.0040.00416.63
8.0.280.0030.00318.45
8.0.270.0030.00316.73
8.0.260.0060.00321.78
8.0.250.0030.00416.83
8.0.240.0070.00016.96
8.0.230.0000.00716.98
8.0.220.0030.00316.95
8.0.210.0000.00716.88
8.0.200.0030.00317.00
8.0.190.0040.00417.02
8.0.180.0030.00516.89
8.0.170.0080.00016.85
8.0.160.0040.00416.81
8.0.150.0000.00716.88
8.0.140.0040.00416.76
8.0.130.0050.00013.41
8.0.120.0000.00816.92
8.0.110.0070.00016.90
8.0.100.0030.00516.88
8.0.90.0090.00016.93
8.0.80.0090.00916.83
8.0.70.0000.00716.89
8.0.60.0000.00716.95
8.0.50.0030.00716.91
8.0.30.0030.01416.88
8.0.20.0150.00616.98
8.0.10.0070.00016.95
8.0.00.0070.01116.70
7.4.330.0000.00515.55
7.4.320.0000.00616.52
7.4.300.0030.00316.52
7.4.290.0000.00716.45
7.4.280.0050.00316.50
7.4.270.0070.00016.50
7.4.260.0000.00613.34
7.4.250.0030.00316.45
7.4.240.0000.00716.56
7.4.230.0070.00016.54
7.4.220.0020.00516.56
7.4.210.0080.00816.64
7.4.200.0030.00316.60
7.4.130.0120.00616.57
7.4.120.0060.01316.51
7.4.110.0110.00516.44
7.4.100.0080.00816.55
7.4.90.0120.00616.52
7.4.80.0090.00919.39
7.4.70.0030.01316.60
7.4.60.0110.01116.51
7.4.50.0030.01016.33
7.4.40.0030.01716.48
7.4.30.0150.00416.00
7.4.20.0110.01115.98
7.4.10.0150.00316.68
7.4.00.0150.00616.37
7.3.330.0030.00316.40
7.3.320.0000.00513.40
7.3.310.0040.00416.36
7.3.300.0040.00416.34
7.3.290.0080.00916.32
7.3.280.0090.01216.19
7.3.260.0190.00016.50
7.3.240.0080.01016.45
7.3.230.0070.01016.41
7.3.210.0190.00416.19
7.3.200.0050.01116.46
7.3.190.0140.00316.43
7.3.180.0100.00616.29
7.3.170.0130.00316.54
7.3.160.0130.00816.14
7.3.150.0050.01116.14
7.3.140.0150.00416.53
7.3.130.0130.00616.36
7.3.120.0060.01016.60
7.3.110.0130.00716.64
7.3.100.0100.01016.50
7.3.90.0080.01216.38
7.3.80.0070.01016.20
7.3.70.0000.01616.27
7.3.60.0100.00716.15
7.3.50.0070.01616.18
7.3.40.0070.01716.20
7.3.30.0090.00916.27
7.3.20.0440.00716.26
7.3.10.0130.00716.12
7.3.00.0180.00916.20
7.2.330.0120.00616.51
7.2.320.0030.01616.95
7.2.310.0110.00616.68
7.2.300.0040.01416.60
7.2.290.0180.00516.39
7.2.280.0160.00816.75
7.2.270.0070.01416.77
7.2.260.0070.01116.64
7.2.250.0130.00316.78
7.2.240.0130.00616.57
7.2.230.0130.00616.19
7.2.220.0040.01416.57
7.2.210.0120.00616.44
7.2.200.0130.00516.54
7.2.190.0090.01216.59
7.2.180.0070.01316.57
7.2.170.0130.00716.39
7.2.160.0040.01616.42
7.2.150.0420.01016.53
7.2.140.0160.00616.42
7.2.130.0100.01016.62
7.2.120.0090.01416.32
7.2.110.0100.01316.53
7.2.100.0030.01616.33
7.2.90.0190.00616.53
7.2.80.0230.00816.43
7.2.70.0100.01316.51
7.2.60.0190.00516.57
7.2.50.0170.01416.68
7.2.40.0240.00716.50
7.2.30.0200.00716.48
7.2.20.0220.00616.58
7.2.10.0170.01416.47
7.2.00.0040.01516.61

preferences:
57.26 ms | 403 KiB | 5 Q