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? Link to comment https://forums.phpfreaks.com/topic/9296-proper-way-to-strip-quotes/ 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... Link to comment https://forums.phpfreaks.com/topic/9296-proper-way-to-strip-quotes/#findComment-34250 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! Link to comment https://forums.phpfreaks.com/topic/9296-proper-way-to-strip-quotes/#findComment-34390 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... Link to comment https://forums.phpfreaks.com/topic/9296-proper-way-to-strip-quotes/#findComment-34730 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.