thegauntlet Posted April 2, 2010 Share Posted April 2, 2010 New to PHP. Having problems with preg_replace. A lot of press releases I post have characters that UTF-8 doesn't like so I am trying to just use preg_replace to replace them with the valid characters. The issue is all the / backslashes get removed in the html, urls, tags, etc. I don't want them removed. My code is below. $article = "$row->article"; $patterns[0] = '/“/'; $patterns[1] = '/’/'; $replacements[0] = '"'; $replacements[1] = '\''; $newarticle = preg_replace($patterns, $replacements, $article); Link to comment https://forums.phpfreaks.com/topic/197371-preg_replace-removing-backslashes/ Share on other sites More sharing options...
monkeytooth Posted April 2, 2010 Share Posted April 2, 2010 Check out this post may help a little bit also, look into "stripslashes" don't know if it removes forward slashes though http://www.phpfreaks.com/forums/index.php?topic=228986.0 Link to comment https://forums.phpfreaks.com/topic/197371-preg_replace-removing-backslashes/#findComment-1036065 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.