3v4l.org

run code in 300+ PHP versions simultaneously
<?php $items = [ (object)['level' => '1', 'title' => 'Home'], (object)['level' => '1', 'title' => 'DIFC'], (object)['level' => '1', 'title' => 'ADGM'], (object)['level' => '1', 'title' => 'About'], (object)['level' => '1', 'title' => 'Publications'], (object)['level' => '2', 'title' => 'FinTech: Now Everybody Wants A Slice of the Pie'], (object)['level' => '2', 'title' => 'The Role of Financial Centres in Emerging Economies'], (object)['level' => '2', 'title' => 'Bitcoin versus Ethereum '], (object)['level' => '1', 'title' => 'ADGM'], (object)['level' => '1', 'title' => 'DIFC'], (object)['level' => '1', 'title' => 'Finance'], (object)['level' => '1', 'title' => 'Contact'] ]; echo '<ul itemscope itemtype="http://www.schema.org/SiteNavigationElement">' . "\n"; foreach ($items as $i => $menu_item) { if($menu_item->level == '1') { if ($i) { // so long as not the first row of results if ($sub_menu) { // only display a batch of submenus if batch is not empty echo "\n\t\t<ul>\n\t\t\t<li>" . implode("</li>\n\t\t\t<li>", $sub_menu) . "</li>\n\t\t</ul>"; } echo "\n\t" . '</li>' . "\n"; } $sub_menu = array(); // start over with a new batch echo "\t" . '<li itemprop="name">' . "\n"; echo "\t\t" . '<a itemprop="url" href="http://www.10leaves.ae/">' . $menu_item->title . '</a>'; } elseif ($menu_item->level == '2') { $sub_menu[] = $menu_item->title; } } if ($items) { echo "\n\t</li>"; } echo "\n</ul>";
Output for git.master_jit, git.master, rfc.property-hooks
<ul itemscope itemtype="http://www.schema.org/SiteNavigationElement"> <li itemprop="name"> <a itemprop="url" href="http://www.10leaves.ae/">Home</a> </li> <li itemprop="name"> <a itemprop="url" href="http://www.10leaves.ae/">DIFC</a> </li> <li itemprop="name"> <a itemprop="url" href="http://www.10leaves.ae/">ADGM</a> </li> <li itemprop="name"> <a itemprop="url" href="http://www.10leaves.ae/">About</a> </li> <li itemprop="name"> <a itemprop="url" href="http://www.10leaves.ae/">Publications</a> <ul> <li>FinTech: Now Everybody Wants A Slice of the Pie</li> <li>The Role of Financial Centres in Emerging Economies</li> <li>Bitcoin versus Ethereum </li> </ul> </li> <li itemprop="name"> <a itemprop="url" href="http://www.10leaves.ae/">ADGM</a> </li> <li itemprop="name"> <a itemprop="url" href="http://www.10leaves.ae/">DIFC</a> </li> <li itemprop="name"> <a itemprop="url" href="http://www.10leaves.ae/">Finance</a> </li> <li itemprop="name"> <a itemprop="url" href="http://www.10leaves.ae/">Contact</a> </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:
38.49 ms | 403 KiB | 8 Q