I have this code for an Export MySQL table to excel file the code is working fine, but Arabic language not working appear as icons how can fix that please!!
Code :
<?php
$stmt = $DB_con->prepare("SELECT * FROM `users` ORDER BY id DESC");
$stmt->execute();
$filelocation = 'file/';
$filename = 'export-'.date('Y-m-d H.i.s').'.csv';
$file_export = $filelocation . $filename;
header( 'Content-Type: text/csv; charset=utf-8; encoding=UTF-8' );
header("Cache-Control: cache, must-revalidate");
header("Pragma: public");
header( 'Content-Disposition: attachment;filename='.$filename.'' );
$data = fopen($file_export, 'w');
$csv_fields = array();
$csv_fields[] = 'id';
$csv_fields[] = 'firstname';
$csv_fields[] = 'lastname';
$csv_fields[] = 'email';
$csv_fields[] = 'city';
$csv_fields[] = 'nationality';
$csv_fields[] = 'phone';
$csv_fields[] = 'mobile';
$csv_fields[] = 'personal';
$csv_fields[] = 'education';
$csv_fields[] = 'interests';
$csv_fields[] = 'skills';
$csv_fields[] = 'hobby';
fputcsv($data, $csv_fields);
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
fputcsv($data, $row);
}
?>