preg_replace with a " as replace

Associate
Joined
18 Oct 2002
Posts
1,312
Location
Milton Keynes
Hey peeps

Am trying to turn an HTML file into a string (will use file_get_contents()), and then turn all of the "s into \"s so that I can echo the string.

Having problems with what to put in the pattern and what t put in replace

I have
PHP:
$file = file_get_contents("file.html");
$pattern = "\"";
$replacement = "\\\"";
echo preg_replace($pattern, $replacement, $file);

I don't get an output at all, anyone tell me *** i'm doing wrong? Its probably something simple lol :cool:
 
Back
Top Bottom