ameliabob Posted February 26, 2012 Share Posted February 26, 2012 I have been scratching my head on how to put a carriage return in a simple text file. I finally went to the php fputcsv example: $list = array("Peter,Griffin,Oslo,Norway","Glenn,Quagmire,Oslo,Norway",);$file = fopen("contacts.csv","w");foreach ($list as $line) { fputcsv($file,split(',',$line)); }fclose($file); This says that the result should be: Peter,Griffin,Oslo,NorwayGlenn,Quagmire,Oslo,Norway But my file comes out: Peter,Griffin,Oslo,NorwayGlenn,Quagmire,Oslo,Norway How did they do that? Link to comment Share on other sites More sharing options...
birbal Posted February 26, 2012 Share Posted February 26, 2012 nm Link to comment Share on other sites More sharing options...
birbal Posted February 26, 2012 Share Posted February 26, 2012 It icomes out that it is using line feed (\n) for each row. It is showing properly if you open it in notepad++,open office, MS excel. They somehow inpret the new line where notepad did not. i belive you used notepad to open that csv file? in windows the new line need to be CR+LF to get a new line where in unix the new line is LF (line feed). If you open the csv file any hex editor you can locate the line feed as value 0a Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.