Home > Backend Development > PHP Tutorial > PHP export CSV php export csv php export csv php create csv fil

PHP export CSV php export csv php export csv php create csv fil

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-29 08:48:55
Original
1094 people have browsed it

//Export 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 = "Property name, whether a return visit has been made";
$str = iconv(' utf-8','gb2312',$str); //Chinese transcoding
if ($data){
foreach ($data as $d){
$name = iconv('utf-8','gb2312' ,$d['house_name']); //Chinese transcoding
$vis = $d['is_visited']=='y'?"Revisited":"No return visit";
$vis = iconv('utf -8','gb2312',$vis);
$str.= $name.",".$vis."n";
}
}
$filename = $date['start']."-" .$date['end'].$city_cn.'Return calls and visits.csv'; //Set the file name
export_csv($filename,$str); //Export

The above introduces PHP export to CSV, including php and csv content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template