I am retrieving an array and I made function to structure the array so it looks tree array. How to make tree menu with list tag (ul, li)
function buildTree(array
Try this example, pass $menuTree variable to buildMenu function.
function buildMenu($menus)
{
$data = '';
foreach ($menus as $key => $menu) {
if ($key == 'children' && !empty($menu)) {
$data .= buildMenu($menu);
continue;
}
$data .= '- '.$menu['title'].'
';
}
if (!empty($data)) {
$data .= ''.$data.'
';
}
return $data;
}