3v4l.org

run code in 300+ PHP versions simultaneously
<?php $lists = array(array( array( 'id' => 1, 'parent' => 0, 'name' => 'Menu 1', ), array( 'id' => 2, 'parent' => 1, 'name' => 'Menu 2', ), array( 'id' => 3, 'parent' => 2, 'name' => 'Menu 3', ), array( 'id' => 4, 'parent' => 1, 'name' => 'Menu 4', ), array( 'id' => 5, 'parent' => 0, 'name' => 'Menu 5', ) )); function make_list($lists, $parent = 0) { $children = array_filter($lists[0], function ($v) use($parent) { return $v['parent'] == $parent; }); if (!count($children)) return; echo "<ul>\n"; foreach ($children as $child) { echo "<li>{$child['name']}</li>\n"; make_list($lists, $child['id']); } echo "</ul>\n"; } make_list($lists);
Output for git.master, git.master_jit, rfc.property-hooks
<ul> <li>Menu 1</li> <ul> <li>Menu 2</li> <ul> <li>Menu 3</li> </ul> <li>Menu 4</li> </ul> <li>Menu 5</li> </ul>

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
58.72 ms | 401 KiB | 8 Q