HughbertD Posted March 5, 2008 Share Posted March 5, 2008 Hi all, I am writing some data to a file (well appending) I am using \n for a new line return, but all I get is a small square, and all the data is on one line $file="export_$time"; $handle=fopen($file,'a'); $data="$start2 TO $end2\n"; fwrite($handle, $data); fclose($handle); Thanks for any help you can give. Link to comment https://forums.phpfreaks.com/topic/94533-writing-to-file-new-line-character-n-doesnt-work/ Share on other sites More sharing options...
cooldude832 Posted March 5, 2008 Share Posted March 5, 2008 try \r\n Link to comment https://forums.phpfreaks.com/topic/94533-writing-to-file-new-line-character-n-doesnt-work/#findComment-484044 Share on other sites More sharing options...
shocker-z Posted March 5, 2008 Share Posted March 5, 2008 If you open it in word or some rich text editor then save it, it will work. It's just the way notepad is. or a less im missing somthing on how to get past it... Give \n\r a try but im sure it does the same. Rgards Liam Link to comment https://forums.phpfreaks.com/topic/94533-writing-to-file-new-line-character-n-doesnt-work/#findComment-484049 Share on other sites More sharing options...
HughbertD Posted March 5, 2008 Author Share Posted March 5, 2008 \r\n worked! Thanks! Link to comment https://forums.phpfreaks.com/topic/94533-writing-to-file-new-line-character-n-doesnt-work/#findComment-484056 Share on other sites More sharing options...
cooldude832 Posted March 5, 2008 Share Posted March 5, 2008 \r\n worked! Thanks! \n = windows systems \r = unix when you use both the version of OS you run ignores the other usually Link to comment https://forums.phpfreaks.com/topic/94533-writing-to-file-new-line-character-n-doesnt-work/#findComment-484059 Share on other sites More sharing options...
discomatt Posted March 5, 2008 Share Posted March 5, 2008 \r\n worked! Thanks! \n = windows systems \r = unix when you use both the version of OS you run ignores the other usually Are you sure? From what I have found through experience, *nix is \n while windows is \r\n Link to comment https://forums.phpfreaks.com/topic/94533-writing-to-file-new-line-character-n-doesnt-work/#findComment-484074 Share on other sites More sharing options...
cooldude832 Posted March 5, 2008 Share Posted March 5, 2008 its something like that I think you might be right, but unix ignores what windows likes and windows ignores what unix likes so you need a catch all to make em both happy usually Link to comment https://forums.phpfreaks.com/topic/94533-writing-to-file-new-line-character-n-doesnt-work/#findComment-484089 Share on other sites More sharing options...
wildteen88 Posted March 5, 2008 Share Posted March 5, 2008 Windows can accept either \r\n or \n as a new lines. It all depends on the application you use to view the generated file. Notepad prefers \r\n for newlines any other new line char and it'll display [] in replacement. Link to comment https://forums.phpfreaks.com/topic/94533-writing-to-file-new-line-character-n-doesnt-work/#findComment-484114 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.