Those are \r characters from dos newline (\r\n). Generally they are not harmful and many editors can work with them without problems (vim). You can use some utility commands to convert to or from dos or unix newlines.

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



Reply via email to