<?php
function recusive_list($items) {
$html = '<ul>';
foreach ($items as $item) {
$html .= '<li>';
$html .= '<a target="_blank" href="' .$item['href']. '">' .$item['name']. '</a>';
$html .= recusive_list($item['childs']). '</li>';
}
$html .= '</ul>';
return $html;
}
$items = [
[
'href' => 'www.item1',
'name' => 'Item1',
'childs' => [
[
'href' => 'www.item1.1',
'name' => 'Item1.1',
'childs' => []
]
]
],
[
'href' => 'www.item2',
'name' => 'Item2',
'childs' => [
[
'href' => 'www.item2.1',
'name' => 'Item2.1',
'childs' => [
[
'href' => 'www.item2.1.1',
'name' => 'Item2.1.1',
'childs' => []
],
[
'href' => 'www.item2.1.2',
'name' => 'Item2.1.2',
'childs' => [
[
'href' => 'www.item2.1.2.1',
'name' => 'Item2.1.2.1',
'childs' => []
]
]
]
]
]
]
],
[
'href' => 'www.item3',
'name' => 'Item3',
'childs' => []
],
];
echo recusive_list($items);
PD9waHAKCmZ1bmN0aW9uIHJlY3VzaXZlX2xpc3QoJGl0ZW1zKSB7CgkkaHRtbCA9ICc8dWw+JzsKCWZvcmVhY2ggKCRpdGVtcyBhcyAkaXRlbSkgewoJCSRodG1sIC49ICc8bGk+JzsKCQkkaHRtbCAuPSAnPGEgdGFyZ2V0PSJfYmxhbmsiIGhyZWY9IicgLiRpdGVtWydocmVmJ10uICciPicgLiRpdGVtWyduYW1lJ10uICc8L2E+JzsKCQkkaHRtbCAuPSByZWN1c2l2ZV9saXN0KCRpdGVtWydjaGlsZHMnXSkuICc8L2xpPic7Cgl9CgkkaHRtbCAuPSAnPC91bD4nOwoJcmV0dXJuICRodG1sOwp9CgokaXRlbXMgPSBbCglbCgkJJ2hyZWYnID0+ICd3d3cuaXRlbTEnLAoJCSduYW1lJyA9PiAnSXRlbTEnLAoJCSdjaGlsZHMnID0+IFsKCQkJWwoJCQkJJ2hyZWYnID0+ICd3d3cuaXRlbTEuMScsCgkJCQknbmFtZScgPT4gJ0l0ZW0xLjEnLAoJCQkJJ2NoaWxkcycgPT4gW10KCQk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