preg_replace ^M

From: Date: Thu, 06 Nov 2003 13:47:23 +0000
Subject: preg_replace ^M
Groups: php.general 
Request: Send a blank email to php-general+get-168712@lists.php.net to get a copy of this message
Hello i try to replace a string in a file but if i have linefeeds in the string the output file after the replacement has ^M carachters in in if the $replacements[] = "test"; has no \n in it all is OK $fp = fopen ("draft.html", "r"); $incont = fread ($fp,filesize("draft.html")); fclose ($fp); $patterns[] = "/\[CONTENT\]/"; $replacements[] = "test\nout"; $content = preg_replace ($patterns,$replacements,$incont); $fp = fopen ("out.html","w"); fputs ($fp, $content); fclose($fp); draft.html looks like: form method="post" [CONTENT] /form the out put get ugly ^M form method="post" ^M SERAVS toro^M ^M /form>^M BR/Torsten

« previous php.general (#168712) next »