menu example - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of menu example.php
- <?php
- $menu = [
- 'First item. NOT drop-down' => [
- 'href' => '/',
- ],
- 'Second item. Drop-down' => [
- 'submenu1' => [
- 'href' => '/submenu',
- ],
- ],
- ];
- ?>
- <ul>
- <?php foreach ($menu as $title => $item) : ?>
- <?php if (in_array('href', array_keys($item))) : ?>
- <li><a href="<?= $item['href'] ?>"><?= $title ?></a></li>
- <?php else: ?>
- <li>
- <ul>
- <?php foreach ($item as $subtitle => $subitem) : ?>
- <li><a href="<?= $subitem['href'] ?>"><?= $subtitle ?></a></li>
- <?php endforeach; ?>
- </ul>
- </li>
- <?php endif; ?>
- <?php endforeach; ?>
- </ul>
File Description
- menu example
- PHP Code
- 23 Aug-2019
- 691 Bytes
You can Share it:
Latest PHP Pastes