stevepatd Posted October 19, 2006 Share Posted October 19, 2006 I have a php file that outputs text to a standard ASCII text file. I put a \n at the end of each line as it writes out. I then have another php file that reads these generated files and does something with the data. The problem is, when the second file reads the generated data it doesn't like the \n. When I edit the generated files with Notepad instead of seeing a carriage return/line feed making the data line up in nice neat columns, I see a little square in place of the \n and the text continues on the same line wrapping at the edge of the screen.WHat command should I be using to prevent this?I'm running on a Windows server, either Win2000 or 2003.Thx,Steve Quote Link to comment https://forums.phpfreaks.com/topic/24405-funny-line-feeds/ Share on other sites More sharing options...
redarrow Posted October 19, 2006 Share Posted October 19, 2006 nl2br(); Quote Link to comment https://forums.phpfreaks.com/topic/24405-funny-line-feeds/#findComment-111045 Share on other sites More sharing options...
Daniel0 Posted October 19, 2006 Share Posted October 19, 2006 It is because Windows uses a carriage return and then a line feed (\r\n) - CRLF.Linux uses a line feed (\n) - LF.Macintosh uses a carriage return (\r) - CR. Quote Link to comment https://forums.phpfreaks.com/topic/24405-funny-line-feeds/#findComment-111074 Share on other sites More sharing options...
btherl Posted October 19, 2006 Share Posted October 19, 2006 If the file is being created in unix and read in windows, you can probably fix it by using \r\n for linefeed instead of \n. If it's some other combination, the solution will be different. nl2br() is for displaying in html, so it doesn't help here. Quote Link to comment https://forums.phpfreaks.com/topic/24405-funny-line-feeds/#findComment-111092 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.