SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2005
    Location
    USA
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help on links space Add %20

    Hello

    Please could anyone Show me how to Remove the Space in links

    i have a script when i add a links example

    http://sitehere.com/444444/4gf4hgf4g4fg4gf44444ghgfhf4

    it became

    http://sitehere.com/444444/4gf4hgf4g 4fg4gf44444ghgfhf4

    or

    http://sitehere.com/444444/4gf4hgf4g4f%20g4gf44444ghgfhf4

    i need to remove this Space/%20

    Here is smiple code from the script

    $link = str_replace("&", "&" , $link);
    $link = str_replace("[" , "%5b", $link);
    $link = str_replace("]" , "%5d", $link);
    $link = preg_replace("/javascript:/i", "java script: ",$link);
    $link = str_replace("<br />" , "", $link);

    if ($skip_it == 1)
    {
    return $link;
    }
    else
    is there any trick something will help me i try "$link = urlencode($link);" but still not work
    Favorite Site : xProxy

  2. #2
    *munch munch* killerkooki's Avatar
    Join Date
    Sep 2004
    Location
    Singapore
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perhaps what you are looking for is urlencode()/urldecode().
    Give it a search in the PHP Manual.

  3. #3
    SitePoint Zealot
    Join Date
    Jan 2005
    Location
    USA
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hello could you please read my last word in the first post i already say that i try urlencode thankyou anyway .. if you could point me to the link i'm just newbie with php
    Favorite Site : xProxy

  4. #4
    SitePoint Member
    Join Date
    Oct 2005
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $link = preg_replace("/\s/","",$link);
    this should work for removing spaces

  5. #5
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,804
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    If you have multiple replaces in one string, put them into arrays.

    PHP Code:

    # array for what to replace..
    $replace=array("&amp""]""[""<br />""%20");
    $replace_with = array("&""%5b""%5d""""");
    $link str_replace($replace$replace_with$link); 
    Mike
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  6. #6
    *munch munch* killerkooki's Avatar
    Join Date
    Sep 2004
    Location
    Singapore
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I must admit that I missed that last line, but, did you try urldecode?
    If you simply want to remove %## values from a url, urldecode should do the trick.

    But I do not understand how the first link can transfrom into the second.
    If you haven't soved it yet, can you try elaborating a bit more?

    Edit:
    Ah, nevermind. I finally understood it. You wanted to be rid of *both* spaces and %20, not one or the other. Sorry about the misunderstanding.

  7. #7
    SitePoint Zealot
    Join Date
    Jan 2005
    Location
    USA
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Innershine
    $link = preg_replace("/\s/","",$link);
    this should work for removing spaces

    WOW This is your first post in this forum you reply to me and it work thanks very much

    also thanks to everyone
    Favorite Site : xProxy

  8. #8
    SitePoint Zealot
    Join Date
    Jan 2005
    Location
    USA
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello

    Now after trying that code it Work there is no space but it's add "<br/>" in the End of the link ..
    $link = str_replace("&amp;", "&" , $link);
    $link = str_replace("[" , "%5b", $link);
    $link = str_replace("]" , "%5d", $link);
    $link = preg_replace("/\s/","",$link);
    $link = preg_replace("/javascript:/i", "java script: ",$link);
    $link = str_replace("<br />" , "", $link);


    @spikeZ when i try your code the space still there and Yes i have Multi Link
    any commants ?
    Favorite Site : xProxy

  9. #9
    SitePoint Member
    Join Date
    Oct 2005
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $link str_replace("&amp;""&" $link);
    $link str_replace("[" "%5b"$link);
    $link str_replace("]" "%5d"$link);
    $link str_replace("<br />" ""$link);
    $link preg_replace("/\s/","",$link);
    $link preg_replace("/javascript:/i""java script: ",$link); 
    try this

  10. #10
    SitePoint Zealot
    Join Date
    Jan 2005
    Location
    USA
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yup Work .. Thanks
    Favorite Site : xProxy


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
  •