Reputation: 479
here is current way i'm doing for generate csv file in php,
$path = $url . 'temp/' .$filename.'.csv';
fputcsv($fp, $heders, ",");
foreach ($new_data as $line) {
fputcsv($fp, $line, ",");
}
fclose($fp);
here is problem which i have,
this is data i have in data set,
Brüel & Kjæ, Type 4226, S/N: 2433646
when generate csv file it's change to this,
Brüel & Kjæ, Type 4226, S/N: 2433646
i need to get exactly same character to csv. please help me to solve this issue :(
Upvotes: 3
Views: 7415
Reputation: 3828
Put this line of code at the top of the file in php:
header('Content-Type: text/html; charset=UTF-8');
Upvotes: 0
Reputation: 845
Try this, set UTF-8 before getting result for both mysqli query and header
1. $mysqli->set_charset("utf8");
and
2. header('Content-type: application/csv');
header('Content-Disposition: attachment; filename=' . $filename);
header("Content-Transfer-Encoding: UTF-8");
header('Pragma: no-cache');
Upvotes: 1