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> > ";
}
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> > ";
$newpath .= '/';
}
print "</div>";
精彩评论