SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot dcgamers's Avatar
    Join Date
    Dec 2005
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool werd thing I need to do with variables

    Ok this is my problem. I have a variable that has a value (a sentence actualy) that has spaces in it. It cannot have spaces. So what I need is a code sniplet that will change a space into a _ or a %20 (which makes a space). How Do I do it?

  2. #2
    SitePoint Wizard silver trophy Jelena's Avatar
    Join Date
    Feb 2005
    Location
    Universum, 3rd Corner
    Posts
    3,000
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $var "Hello World. This is me.";
    $new_var  str_replace(" ""_"$var);
    echo 
    $new_var
    -- Jelena --

  3. #3
    Non-Member I87's Avatar
    Join Date
    Mar 2006
    Location
    UK
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $thing = "whatever *****";
    $thing_two = str_replace(" ", "%20", $thing);

  4. #4
    Non-Member I87's Avatar
    Join Date
    Mar 2006
    Location
    UK
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    whoops
    I was too late

  5. #5
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    just making a guess here, maybe your intrested in this function

    urlencode()

  6. #6
    SitePoint Zealot dcgamers's Avatar
    Join Date
    Dec 2005
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no, jelena's code worked. Thanks.


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
  •