i am using recursive function to echo multi-level navigation scheme in code-igniter it echo's fine but i want to combine that output in one varible and want to return it from where the function is called please, help me here is my code
function parseAndPrintTree($root, $tree)
{
if(!is_null($tree) && count($tree) > 0)
{
echo 'ul';
foreach($tree as $child => $parent)
{
if($parent->parent == $root)
{
unset($tree[$child]);
echo 'li';
echo $parent->name;
parseAndPrintTree($parent->entity_id, $tree);
echo 'li close';
}
}
echo 'ul close';
}
}