当前位置:Gxlcms > PHP教程 > PHP导出CSVphp导出csvphpexportcsvphpcreatecsvfil

PHP导出CSVphp导出csvphpexportcsvphpcreatecsvfil

时间:2021-07-01 10:21:17 帮助过:25人阅读

//导出csv
function export_csv($filename,$data) {
header("Content-type:text/csv;charset=utf-8");
header("Content-Disposition:attachment;filename=".$filename);
header('Cache-Control:must-revalidate,post-check=0,pre-check=0');
header('Expires:0');
header('Pragma:public');
echo $data;
}
$data = $component->getFeedBackList($city_en,$date,0,0);
$str = "楼盘名,是否已回访\n";
$str = iconv('utf-8','gb2312',$str); //中文转码
if ($data){
foreach ($data as $d){
$name = iconv('utf-8','gb2312',$d['house_name']); //中文转码
$vis = $d['is_visited']=='y'?"已回访":"未回访";
$vis = iconv('utf-8','gb2312',$vis);
$str.= $name.",".$vis."\n";
}
}
$filename = $date['start']."-".$date['end'].$city_cn.'来电回访情况.csv'; //设置文件名
export_csv($filename,$str); //导出

以上就介绍了PHP导出CSV,包括了php,csv方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

人气教程排行