//適用於不須要設置格式簡單將數據導出的程序,多多指教......函數
$str .= 'pro_code'.','.'words'.'\n';//首先寫入表格標題欄post
foreach($is_error as $key => $value){//循環寫入數據code
$str .= $value['pro_code'].",".$value['words']."\n";utf-8
}it
$str = iconv('utf-8','gb2312',$str);//防止中文亂碼io
$filename = "./output.csv";//文件路徑及名字function
export_csv($filename,$str); //導出亂碼
//自定義輸出函數
function export_csv($filename,$str){date
header("Content-type:text/csv");foreach
header("Content-Disposition:attachment;filename=".$filename);
header('Cache-Control:must-revalidate,post-check=0,pre-check=0');
header('Expires:0');
header('Pragma:public');
echo $str;
}