Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: String Replace

  1. #1
    Regular Coder
    Join Date
    Apr 2006
    Posts
    231
    Thanks
    9
    Thanked 1 Time in 1 Post

    String Replace

    Hey All,

    I'm having some URL/SEO Issues. I have a video website, and for the sake of SEO, I put ?video=blah instead of ?videoid=##. Now, the spaces are replaced with %20. This is really bad when it comes to SEO. A user will probably not click something that has a bunch of %20s and such when they see it on an seo.

    Now, Is there a php way of replacing certain letters in a string?

    I got: $foo="Coding Forums";
    I want: $foo="Coding_Forums";

    *Note, I don't make urls, they are automatically generated off of the mysql.

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts

  • #3
    Regular Coder
    Join Date
    Dec 2006
    Location
    In the wilderness
    Posts
    106
    Thanks
    9
    Thanked 5 Times in 5 Posts
    PHP Code:
    <?php
    $foo
    "coding forums";
    $foo_rep str_replace(" ","_",$foo);

    echo 
    $foo_rep;
    ?>
    "The advantage of computers is that they do exactly what you tell them to do. The disadvantage of computers, on the other hand, is that they do exactly what you tell them to do."

    Excellent resource for learning PHP here

  • #4
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    This is really bad when it comes to SEO. A user will probably not click something that has a bunch of %20s and such when they see it on an seo.
    SEO stands for Search Engine Optimization. All you're doing is making it more likely that a search engine will pick you for their results. By adding the keywords in the URL, etc. The spaces aren't going to matter. And people hardly look at more than the first parts of a URL (the domain name).


  •  

    Posting Permissions

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