based on this array mentioned here :
I am trying to generate breadcrumb like this
main>link1>link2>link3
main>link1>link2
main>link1
this is i am going
function GenerateBreadcrumbHTML($nav) {
$html = '';
foreach ($nav as $page) {
$html .= '';
$html .= '<a href="' . $page['link'] . '">' . $page['name'] . '</a> >';
$html .= GenerateBreadcrumbHTML($page['sub']);
$html .= '</br>';
}
return $html;
}
but i am getting output as:
main cat 1 >sub main of 1 >
sub main of 1 >
main cat 2 >sub main of 2 >
sub main of 2 >
main cat 3 >sub main of 3 >
sub main of 3 >
main cat 4 >sub main of 4 >sub cat of 11 >
sub main of 4 >
please explain me the logic so that i can get the desired result.