I put the below function inside a class
I try to call it again inside this function (I have made a recursive call inside this function $this->buildMenu($this->itemId, $menuData);)
only without the recursive call this function works, else it does not return any value.
// menu builder function, parent_id 0 is the root
function buildMenu($parent_id, $menuData)
{
$this->html = '';
if (isset($menuData['parents'][$parent_id]))
{
if($parent_id=='0') $this->html = '<ul class="menu responsive-menu sf-js-enabled">';
else $this->html = '<ul>';
foreach ($menuData['parents'][$parent_id] as $this->itemId)
{
if($this->itemId=='1'){$this->html .= '<li><a href="'.PATH.'">' . $menuData['items'][$this->itemId]['menu_name'].'</a>';}
else $this->html .= '<li class=""><a href="?action='. md5($menuData['items'][$this->itemId]['menu_link']).'">' . $menuData['items'][$this->itemId]['menu_name'].'</a>';
$this->html .= $this->buildMenu($this->itemId, $menuData);
$this->html .= '</li>';
}
$this->html .= '</ul>';
}
return $this->html;
}
$this->itemIdis being changed at all