【发布时间】:2014-10-08 11:21:41
【问题描述】:
我想在一个csv文件中写入2个数组并水平显示。
数组 1
Array
(
[0] => Array
(
[0] => 501
[1] => 8921
)
[1] => Array
(
[0] => 502
[1] => 8446
)
)
数组 2
Array
(
[0] => Array
(
[0] => 501
[1] => 8900
)
[1] => Array
(
[0] => 502
[1] => 8436
)
)
要写入 csv 文件的代码:
header("Content-type: text/csv; charset=utf-8; encoding=utf-8");
header("Content-Disposition: attachment; filename={$exportFileName}.csv");
header("Pragma: no-cache");
header("Expires: 0");
$file = fopen('php://output', 'w');
fputcsv($file, array('HID', 'WEEK1', 'HID', 'WEEK2'));
foreach ($fweek as $k=>$row)
{
fputcsv($file, $row); // I want to include $sweek as well
}
但目前,它只显示第一个数组。
任何提示/建议都会有很大帮助。提前致谢。
【问题讨论】: