【发布时间】:2015-04-15 07:49:23
【问题描述】:
我有一个数组数组,我正在尝试将数组插入 csv 文件。
这是我的代码
$file = 'a.csv'; //path to the file on disk
$fp = fopen($file, 'w') or die('Cannot open file: '.$file);
foreach ($column as $fields) {
print ($fields);
fputcsv($fp, $fields);
}
fclose($fp);
数据是这个
$column = (
(1,2,3), (a,b,c)
)
我想要这样的输出
1,2,3
a,b,c
但我得到这样的输出
1,2,3,a,b,c
【问题讨论】:
-
您的查询具体是什么?新行未插入输出 csv 文件或浏览器?
-
新行没有插入到 csv 文件中
-
会不会有一个“\n”作为换行符,而您的编辑器就是不理解(比如 notepad.exe)?
-
我用excel打开它
-
实际上逗号在两行之间