Torsten Rosenberger wrote:
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
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php