开发者

PHP: breadcrumb path?

i wonder if you could help me building a little breadcrumb path with php.

        print $path; // /folder/subfolder/subfolder/etc
    // breadcrumb path
    $crumb = explode("/", $path);
    print "<div class='breadcrumbs'>";
    foreach($crumb as $value) {
        print "<a href='?p=". $va开发者_开发问答lue ."'>$value</a> &gt; ";
    }
    print "</div>";

the breadcrumbs get printed exactly the way i want them, however i've no idea how i could link every breadcrumb to it's relative path.

e.g. if the current $path is /folder/subfolder/subfolder/etc the the first link (folder) would link to ?p=folder, the second link (subfolder) would link to ?p=subfolder and so on. however the second link has to be ?p=folder/subfolder and not just ?p=folder.

any idea how i could solve that?


$crumb = explode("/", $path);
print "<div class='breadcrumbs'>";
$newpath = '';
foreach($crumb as $value) {
    $newpath .= $value;
    print "<a href='?p=". $newpath ."'>$value</a> &gt; ";
    $newpath .= '/';
}
print "</div>";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜