note 115543 deleted from function.fputcsv by salathe
| From: | salathe@php.net | Date: | Fri, 22 Aug 2014 08:08:31 +0000 |
| Subject: | note 115543 deleted from function.fputcsv by salathe | ||
| References: | 1 | Groups: | php.notes php.notes |
| Request: | Send a blank email to php-notes+get-200253@lists.php.net to get a copy of this message | ||
Note Submitter: pcgamerxone at msn.com
----
if you want to change the line endings for fputcsv to \r\n. after you call fputcsv add a fseek with
ftell then fputs the line ending you want
example
$fp = fopen($file, 'w+');
//add BOM to fix UTF-8 in Excel
fputs($fp, chr(0xEF) . chr(0xBB) . chr(0xBF) );
foreach($data as $fields) {
fputcsv($fp, $fields);
fseek($fp, ftell($fp)-1);
fputs($fp, "\r\n");
}
fclose($fp)