note 118697 added to function.fputcsv
| From: | BiniamNigusse | Date: | Wed, 20 Jan 2016 16:52:19 +0000 |
| Subject: | note 118697 added to function.fputcsv | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-204736@lists.php.net to get a copy of this message | ||
the solution for how to solve the encoding problem while converting an array to csv file is below.
$fp = fopen('php://memory', 'w');
//add BOM to fix UTF-8 in Excel
fputs($fp, $bom =( chr(0xEF) . chr(0xBB) . chr(0xBF) ));
// output the column headings
//fputcsv($fp, array('Topic', 'Title', 'URL', 'Keywords',
'Score', 'FB_count', 'TW_count', '|'));
if(isset($trend)){
foreach ( $trend as $myField ){
fputcsv($fp, $myField, '|');
}
}
----
Server IP: 72.52.91.14
Probable Submitter: 89.97.212.74
----
Manual Page -- http://php.net/manual/en/function.fputcsv.php
Edit -- https://master.php.net/note/edit/118697
Del: integrated -- https://master.php.net/note/delete/118697/integrated
Del: useless -- https://master.php.net/note/delete/118697/useless
Del: bad code -- https://master.php.net/note/delete/118697/bad+code
Del: spam -- https://master.php.net/note/delete/118697/spam
Del: non-english -- https://master.php.net/note/delete/118697/non-english
Del: in docs -- https://master.php.net/note/delete/118697/in+docs
Del: other reasons-- https://master.php.net/note/delete/118697
Reject -- https://master.php.net/note/reject/118697
Search -- https://master.php.net/manage/user-notes.php