fputcsv从第6行开始写。想从第一排

时间:2015-02-23 05:33:28

标签: php csv export-to-csv fputcsv

fputcsv函数从第6行写入数据。但我想从第一行写入数据。

我尝试了什么

// disable caching
$now = gmdate("D, d M Y H:i:s");
header("Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate");
header("Last-Modified: {$now} GMT");
// force download  
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");

// disposition / encoding on response body
header("Content-Disposition: attachment;filename={$filename}");
header("Content-Transfer-Encoding: binary");
$df = fopen("php://output", 'w');
fputcsv($df, array_keys(reset($array)));
foreach ($array as $row) {
      fputcsv($df, $row);
}
fclose($df);

MS-Excel中的内容

enter image description here

在记事本中看起来像什么 enter image description here

0 个答案:

没有答案