What is the best way to do the following:
I get a path with an AJAX request
e.g. dir1/dir2/dir3/dir4
I need to present it like this on my we
I'd do it like this...
0) {
$link = '/' . implode($dirs, '/');
$text = array_pop($dirs);
$breadcrumb = "$text" . $breadcrumb;
if (count($dirs) > 0) {
$breadcrumb = ' >> ' . $breadcrumb;
}
}
echo $breadcrumb;
If you are getting this path based on the URL you shouldn't need to use DIRECTORY_SEPARATOR
because URLs should always use /
. If it is derived from the filesystem path you would need to swap it in instead of '/'
on line 4.