replacing & with &

Discussion in 'PHP' started by dethfire, Jul 2, 2008.

  1. #1
    If I have a URL in say $rss_item['LINK'] and I want to replace the & with & how would I do that in php?
     
    dethfire, Jul 2, 2008 IP
  2. Nick_Mayhem

    Nick_Mayhem Notable Member

    Messages:
    3,486
    Likes Received:
    338
    Best Answers:
    0
    Trophy Points:
    290
    #2
    Nick_Mayhem, Jul 2, 2008 IP
  3. dethfire

    dethfire Well-Known Member

    Messages:
    230
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    118
    #3
    so it would be this?

    $rss_item['LINK'] = str_replace("&","&",$rss_item['LINK']);
     
    dethfire, Jul 2, 2008 IP
  4. AliasXNeo

    AliasXNeo Banned

    Messages:
    151
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yes that would be the correct usage.
     
    AliasXNeo, Jul 2, 2008 IP
  5. serialCoder

    serialCoder Guest

    Best Answers:
    0
    #5
    you can use the function urlencode, its built specifically for this
     
    serialCoder, Jul 2, 2008 IP
  6. RyanDoubleyou

    RyanDoubleyou Peon

    Messages:
    86
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Serial, can you provide a link with more info?
     
    RyanDoubleyou, Jul 2, 2008 IP
  7. serialCoder

    serialCoder Guest

    Best Answers:
    0
  8. RyanDoubleyou

    RyanDoubleyou Peon

    Messages:
    86
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Thank you, will check this out. :D Is there one that can replace " " with %20? I did it, but the html reads it as a %20 and not a space. Oh, and I did the space replace with str_replace
     
    RyanDoubleyou, Jul 2, 2008 IP
  9. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #9
    jayshah, Jul 2, 2008 IP
  10. serialCoder

    serialCoder Guest

    Best Answers:
    0
    #10
    well, it actually does replace a space with %20 but if you want to output it back as a space you might consider urldecode which converts it back, anyways you can check out the manual for the complete details, hope it helps you
     
    serialCoder, Jul 2, 2008 IP
  11. WebLOADER

    WebLOADER Well-Known Member

    Messages:
    118
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #11
    
    $str=$rss_item['LINK'];
    $str=str_replace("&","&",$str);
    
    PHP:
     
    WebLOADER, Jul 2, 2008 IP