my php breadcrumb code is below and the problem is, this is my directory
http://domain.com/folder
using the code below i get directory like this
Ho
Start the for
loop which uses $i
as index with initial value 2 instead of 1.
<?php
$file = basename("/".$_SERVER["PHP_SELF"]);
$filename = (count(explode('.', $file)) === 1 ? $file : implode('.', array_slice(explode('.', $file), 0, (count(explode('.', $file))-1))));
$Pages = array(
$filename => 'Folder'
);
$path = "/".$_SERVER["PHP_SELF"];
$parts = explode('/',$path);
if (count($parts) < 2)
{
echo("home");
}
else
{
echo ("<a href=\"http://domain.com\">Home</a> ");
$cnt = count($parts);
for ($i = 1; $i < $cnt; $i++)
{
if (!strstr($parts[$i],"."))
{
echo("» <a href=\"");
for ($j = 0; $j <= $i; $j++) {echo $parts[$j]."/";};
echo("\">". str_replace('-', ' ', $Pages[$parts[$i]])."</a> ");
}
else
{
$str = $parts[$i];
$pos = strrpos($str,".");
$parts[$i] = substr($str, 0, $pos);
echo str_replace('-', ' ', $Pages[$parts[$i]]);
};
};
};
?>