Icaros Posted May 8, 2006 Share Posted May 8, 2006 i've tried using the following to remove double quotes (i'll get to single eventually) from a string that the user can enter, but it's removing the entire word in quotes.example:blah blah "blah"returns:blah blahshould be:blah blah blah$fixcomment = str_replace("\x22", "", $comment);or$fixcomment = str_replace("\"", "", $comment);any ideas? Quote Link to comment Share on other sites More sharing options...
zq29 Posted May 8, 2006 Share Posted May 8, 2006 The last thing you tried: [code]$fixcomment = str_replace("\"", "", $comment);[/code] That should work... Quote Link to comment Share on other sites More sharing options...
Icaros Posted May 8, 2006 Author Share Posted May 8, 2006 OK i got it to work, but it's a strange solution! //Strip quotes $fixcomment2 = str_replace('\"', '', $comment); $comment = $fixcomment2; $fixcomment2 = str_replace("\'", "", $comment); $comment = $fixcomment2;notice that for double quotes, i need to use single quotes (' \" '), but for single quotes i needed to use double (" \' "). it didn't work any other way! Quote Link to comment Share on other sites More sharing options...
zq29 Posted May 9, 2006 Share Posted May 9, 2006 Thats strange, str_replace("\"", "", $comment) should work fine, as long as the middle quotation mark is escaped... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.