]]]]]]]]]] - 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 ]]]]]]]]]].php
- <?php
- $menu = [];
- $ob = CIBlockSection::GetList(['left_margin' => 'asc', 'sort' => 'asc'], ['IBLOCK_ID' => 6, 'ACTIVE' => 'Y']);
- while ($section = $ob->GetNext()) {
- if ($section['IBLOCK_SECTION_ID']) {
- $menu[$section['IBLOCK_SECTION_ID']]['_child'][$section['ID']] = $section;
- } else {
- $menu[$section['ID']] = $section;
- }
- }
- ?>
- <ul class="menu">
- <?
- foreach ($menu as $item) {
- if (!$item['ID']) {
- continue;
- }
- $current = strpos($_SERVER['REQUEST_URI'], $item['SECTION_PAGE_URL']) === 0;
- ?>
- <li><a <?
- if ($current) {
- ?>
- class="act"
- <?
- }
- ?> href="<?= $item['SECTION_PAGE_URL'] ?>"><?= $item['NAME'] ?></a>
- <?
- if ($current && $item['_child']) {
- ?>
- <div class="menu-child">
- <?
- foreach ($item['_child'] as $child) {
- $current = strpos($_SERVER['REQUEST_URI'], $child['SECTION_PAGE_URL']) === 0;
- ?>
- <a href="<?= $child['SECTION_PAGE_URL'] ?>"<?
- if ($current) {
- ?>
- class="current"
- <?
- }
- ?>><?= $child['NAME'] ?></a>
- <?
- }
- ?>
- </div>
- <?
- }
- ?>
- </li>
- <?
- }
- ?>
- </ul>