PHPverse 2025

Voting

: max(zero, six)?
(Example: nine)

The Note You're Voting On

Biniam Nigusse
9 years ago
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, '|');
}
}

<< Back to user notes page

To Top