$filename = empty($filename) ? time().'.csv' : $filename.'.csv';
$data = chr(255) . chr(254) . mb_convert_encoding($data, 'UTF-16LE', 'UTF-8');
header("Content-type:application/csv");
header("Expires: 0");
header("Cache-Control: must-revalidate");
header('Content-Disposition: attachment; filename=' . $filename);
echo $data;
exit;
当我导出到csv时,我得到的输出如下:“ÿþ”。所以我需要删除这个字符我该怎么做。
答案 0 :(得分:0)
试试这个:
$filename = empty($filename) ? time().'.csv' : $filename.'.csv';
$data = chr(255) . chr(254) . mb_convert_encoding($data, 'UTF-16LE', 'UTF-8');
$cleanedData = str_replace ( "ÿþID", "" , $data);
header("Content-type:application/csv");
header("Expires: 0");
header("Cache-Control: must-revalidate");
header('Content-Disposition: attachment; filename=' . $filename);
echo $cleanedData;
exit;