how do i strip backslashed \ out of an url in php???

Discussion in 'PHP' started by thumbnailspro, Jul 16, 2008.

  1. #1
    tried several methods and this seems almost impossible???

    help... please....

    
    $website_url = str_replace('\', '/', $website_url);
    
    PHP:
    the above code does not work... have tried '\"\"\' weird stuff no luck!

    anyone know how to do this?
     
    thumbnailspro, Jul 16, 2008 IP
  2. edual200

    edual200 Active Member

    Messages:
    309
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #2
    your example has $website_url before and after, not that im 100% sure how to do it but if your trying to remove the / then i think it should be done like this...

    
    $website_url = str_replace('/', '', $stripped_url);
    
    PHP:
     
    edual200, Jul 16, 2008 IP
  3. sastro

    sastro Well-Known Member

    Messages:
    214
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    105
    #3
    Here it is.
    $website_url = str_replace('\\', '/', $website_url);
     
    sastro, Jul 16, 2008 IP
  4. thumbnailspro

    thumbnailspro Peon

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thank you so much sastro... if GAS was cheaper i'd pay you for the solution! good luck with your ventures!
     
    thumbnailspro, Jul 16, 2008 IP
  5. nidz

    nidz Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Try this dude...:D

    $formated_url = stripslashes($unformated_url);
     
    nidz, Jul 20, 2008 IP
  6. blueparukia

    blueparukia Well-Known Member

    Messages:
    1,564
    Likes Received:
    71
    Best Answers:
    7
    Trophy Points:
    160
    #6
    Yes, stripslashes would make more sense.
     
    blueparukia, Jul 21, 2008 IP
  7. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #7
    Well if sastro's code was what he needed, then stripslashes() doesn't make sense at all.
     
    nico_swd, Jul 21, 2008 IP
  8. blueparukia

    blueparukia Well-Known Member

    Messages:
    1,564
    Likes Received:
    71
    Best Answers:
    7
    Trophy Points:
    160
    #8
    Well, I have the habit of reading titles and glazing over code in posts. But yeah you're right.

    Removing slashes you'd use stripslashes, for replaceing backslashes with forward slashes, you'd use sastros :S
     
    blueparukia, Jul 21, 2008 IP
  9. ahowell

    ahowell Peon

    Messages:
    38
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #9
    To ammend Sastros code, You should use 'DIRECTORY_SEPERATOR' for true portability

    $website_url = str_replace('\\', DIRECTORY_SEPERATOR, $website_url);
    PHP:
     
    ahowell, Jul 21, 2008 IP