Jump to content

preg_replace removing backslashes


thegauntlet

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.