|
Posted by "Richard Lynch" on 08/25/05 11:32
On Wed, August 24, 2005 8:33 am, Dotan Cohen wrote:
> I seem to be having trouble with \n and \r in variables. I write my
> code on a linux box, and the server is linux. So I should always have
> \n\r, no? Is there a way the I could print $variable; and have it show
> me the /n and /r 's ? I tried with a srt_replace() on /n and on /r,
> but they do not get replaced. I also tried escaping the backslash,
> then double escaping that as was suggested somewhere in the
> php.net/manual, then triple escaping!
Windows uses \r\n
Linux uses \n
Mac uses \r
Depending on what tools you use to read/write/create the files, and
where the data comes from, it's possible that you have any of those
formats.
This is especially true of FORM data from a TEXTAREA.
I frequently do this:
$text = $_POST['text'];
$text = str_replace("\r\n", "\n", $text);
$text = str_replace("\r", "\n", $text);
//Now I *know* it's in Linux newline format.
--
Like Music?
http://l-i-e.com/artists.htm
[Back to original message]
|