str_replace not working on "

Discussion in 'PHP' started by adeibiza, Nov 7, 2008.

  1. #1
    i'm using the following - and have tried various combinations but the " in the database is not being converted

    the ' is being replaced correctly though

    function parseToXML1($htmlStr) 
    { 
    $xmlStr=str_replace('"','& #039;',$htmlStr); 
    $xmlStr=str_replace("'",'& #039;',$htmlStr); 
    
    return $xmlStr; 
    
    }
    Code (markup):
    (ive deliberatly put a space in this post here: '& #039;' )
     
    adeibiza, Nov 7, 2008 IP
  2. Lordo

    Lordo Well-Known Member

    Messages:
    2,082
    Likes Received:
    58
    Best Answers:
    0
    Trophy Points:
    190
    #2
    It is your bad :)
    The second line should str_replace something in $xmlStr not $htmlStr :)
     
    Lordo, Nov 7, 2008 IP
  3. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #3
    Yeah careless

    $xmlStr=str_replace('"','& #039;',$htmlStr); 
    $xmlStr=str_replace("'",'& #039;',$xmlStr); 
    
    PHP:
     
    ads2help, Nov 7, 2008 IP
  4. adeibiza

    adeibiza Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    aaah :)

    cheers
     
    adeibiza, Nov 7, 2008 IP