Junior — Senior
HTML menu generation from a nested array
livecode
Task condition
It is necessary to convert a nested array into HTML menu markup. The input data is a multidimensional array where each element can contain keys label, url, and optionally items — an array of child items. The task is to traverse the structure and output the corresponding <ul>/<li> list with links.
<?php
$navItems = [
[
'label' => 'Yil framework',
'url' => 'https://yilframework.ru',
],
[
'label' => 'More Frameworks',
'items' => [
['label' => 'Laravel', 'url' => 'http://laravel.com/'],
['label' => 'Slim', 'url' => 'http://www.slimframework.com/'],
],
],
[
'label' => 'Symfony',
'url' => 'https://symfony.com/',
],
];
?>