嗨,我想在php中制作可下载的csv (Apostrophe (') Separated)表单
我正在使用代码-
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=sheet.csv');
$output = fopen('php://output', 'w');
fputcsv($output, array('header1','header2','header3'));
现在在这个我可以下载csv文件(逗号分隔,但我希望csv文件撇号(')分隔,同时运行页面)
RTM
int fputcsv ( resource $handle , array $fields [, string $delimiter = "," [, string $enclosure = '"' ]] )
:
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=sheet.csv');
$output = fopen('php://output', 'w');
fputcsv($output, array('header1','header2','header3'), "'");
http://www.php.net//manual/en/function.fputcsv.php
你只需要在调用fputcsv
:
fputcsv($output, array('header1','header2','header3'), "'");
如果你想提供文件,你所需要做的就是输出它
echo file_get_contents("php://output");