Page 1 of 1

Problem with new lines at the end while appending?

Posted: Sun Jul 10, 2005 8:45 am
by IceMetalPunk
I have a PHP file hosted on a Windows server. Whenever I write a text file with it, the new line character writes fine. However, if I open a file for APPENDING and I try to add a new line to the begining with nothing before it, or to the end with nothing after it, it doesn't work. I need this because I'm using explode() to explode its contents at the line breaks. I know I could use a different character, but the line breaks make it much easier to read if I have to manually edit something. For example, if I open a file for appending only, and I write this to it: "\r\nHello" Hello appears, but there is no blank line above it. And if I type this: "Hello\r\n", there's no new line after Hello. But, if I do this: "Hello\r\nHi", then it works, and there IS a line between the 2 words.

Has this ever happened to anyone? If so, is there a way to fix it?

-IMP ;) :)

*EDIT* Of course, the blue are's are supposed to be the lower-case letter (*stupid filters*)

Posted: Sun Jul 10, 2005 12:35 pm
by lostboy
windows prefers \r\n as a new line separator

Posted: Sun Jul 10, 2005 2:41 pm
by IceMetalPunk
Umm.... that's what I'm using.... It works fine when I have something before/after it, but not at the end or the beginning of the file....

-IMP ;) :)