I was having a tough time with a Mac file uploaded and squeezed into one line. My friend Shawn helped me write the following which cleans it up. Remove the echo statement to just change it and not see the change. Also, avoid trying to fix the file, make a new one, if you can.
Hope this helps. Josh 1 <? 2 $data_file = "data.csv"; 3 $newdatafile = "new_data.csv"; 4 5 $file=fopen($data_file, "r"); 6 $newfile = fopen($newdatafile,"w"); 7 8 $filecontents = fread($file,filesize($data_file)); 9 echo $filecontents; 10 echo "<br><br>"; 11 $newfilecontents = preg_replace("(\r\n|\n|\r)","\n",$filecontents); 12 13 echo nl2br($newfilecontents); 14 15 fwrite($newfile,$newfilecontents); 16 fclose($file); 17 fclose($newfile); 18 ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php