Need help adding str_replace('-',' ',$name); to this simple script

That (or a form of that) replaces “-” with a space. Can you please help me add that to this small breadcrumbs script? Or a version of your own making that does the same thing? Thanks

<?php
$path = $_SERVER["PHP_SELF"];
$parts = explode('/',$path);
if (count($parts) < 2)
{
echo("home");
}
else
{
echo ("<a href=\\"/index.php\\">home</a> &raquo; ");
for ($i = 1; $i < count($parts); $i++)
    {
    if (!strstr($parts[$i],"."))
        {
        echo("<a href=\\"");
        for ($j = 0; $j <= $i; $j++) {echo $parts[$j]."/";};
        echo("\\">".$parts[$i]."</a> &raquo; ");
        }
    else
        {
        $str = $parts[$i];
        $pos = strrpos($str,".");
        $parts[$i] = substr($str, 0, $pos);
        echo $parts[$i];
        };
    };
};
 			?>

Is this what you’re trying to achieve? Replacing the ‘-’ on the output, but keeping it in the link?


<?php 
$path = $_SERVER["PHP_SELF"];
$parts = explode('/',$path);
if (count($parts) < 2)
{
echo("home");
}
else
{
echo ("<a href=\\"/index.php\\">home</a> &raquo; ");
for ($i = 1; $i < count($parts); $i++)
    {
    if (!strstr($parts[$i],"."))
        {
        echo("<a href=\\"");
        for ($j = 0; $j <= $i; $j++) {echo $parts[$j]."/";};
        echo("\\">". str_replace('-', ' ', $parts[$i])."</a> &raquo; ");
        }
    else
        {
        $str = $parts[$i];
        $pos = strrpos($str,".");
        $parts[$i] = substr($str, 0, $pos);
        echo str_replace('-', ' ', $parts[$i]);
        };
    };
};  
?>

Thanks! Ya it’s a breadcrumb script. So I don’t want to touch the URL. I just want to remove the - from the populated breadcrumbs when they are in the link. I also realized I need to strip the .php off the end of the file name in the populated breadcrumb. Can you put that together? Thanks!

Unless I’m missing something, I believe your script already strips the *.php off the end. I put it in a random directory on my server and here’s the output:
http://harrytran.com/some/direc-tory/crumb.php

home >> some >> direct tory >> crumb

That worked perfect. That was am easy edit huh. Still over my head. And you are right. It does already strip the extensions. I don’t know what I was looking at before. Thanks alot. Tis little script does what 10 pages of code does in similar scripts.

Yeah, PHP is pretty simple once you get the hang of it; people will make fun of you for re-inventing the wheel (making scripts that already do what other scripts can do), but I think that’s the best way to learn.

Good morning,

OK I have another hopefully simple one for you. Is there a way to wrap the file name in a span in the populated output?

Reason being I want to enlarge the arrows. So I say the container font size 15px and the anchors font size 12px. Only problem the file name is not a anchor. Thanks

Forget it I figured it out. I just wrapped the arrows in a B. Easy