SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,657
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)

    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

    Code PHP:
    <?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];
            };
        };
    };  
     			?>

  2. #2
    SitePoint Enthusiast harriouz's Avatar
    Join Date
    Jan 2006
    Location
    Chicago
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is this what you're trying to achieve? Replacing the '-' on the output, but keeping it in the link?

    Code:
    <?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]);
            };
        };
    };  
    ?>
    hoang harry tran [harrytran.com]
    get RICH quick by going to my site. rich in useless knowledge

    recently redesigned the site, witness its greatness

  3. #3
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,657
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    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!

  4. #4
    SitePoint Enthusiast harriouz's Avatar
    Join Date
    Jan 2006
    Location
    Chicago
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by EricWatson View Post
    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
    hoang harry tran [harrytran.com]
    get RICH quick by going to my site. rich in useless knowledge

    recently redesigned the site, witness its greatness

  5. #5
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,657
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    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.

  6. #6
    SitePoint Enthusiast harriouz's Avatar
    Join Date
    Jan 2006
    Location
    Chicago
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by EricWatson View Post
    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.
    hoang harry tran [harrytran.com]
    get RICH quick by going to my site. rich in useless knowledge

    recently redesigned the site, witness its greatness

  7. #7
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,657
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    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

  8. #8
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,657
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    Forget it I figured it out. I just wrapped the arrows in a B. Easy


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •