based on this array mentioned here :
我正在尝试像这样生成面包屑
main>link1>link2>link3
main>link1>link2
main>link1
这是我要去的
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;
}
但我得到的输出为:
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 >
请告诉我逻辑,以便我能得到理想的结果。