用fputcsv写CSV

时间:2016-04-24 11:27:58

标签: php fputcsv

当我使用此代码时,新的CVS文件以空白的方式获取HashMap<String,String> map = (HashMap) JSONUtil.deserialize(string) accountVo.setAccountNumber(map.get("accountNumber")); ....

""

原始CSV:

  

Reit im Winkel,69.8,131,68.4,126,71.6,129,69.5,127,70,7,4,5,4,13,5,3,4,1,4,9,4,17 ,3,15,3,11,4,10,4,14,4,18,3,4,4,2,4,8,3,16,5,6,3,12,5,00438640798250

新文件:

  

“Reit im Winkl”,69.8,131,68.4,126,71.6,129,69.5,127,70,7,4,5,4,13,5,3,4,1,4,9,4 ,17,3,15,3,11,4,10,4,14,4,18,3,4,4,2,4,8,3,16,5,6,3,12,5,00438640798250

如何在没有//array in csv schreiben $daten = array_filter($daten); $csv_array[] = $daten; $fp = fopen("golfDBtest.csv", 'w'); foreach ($csv_array as $fields) { fputcsv($fp, $fields); } fclose($fp); 的情况下编写CVS?

由于

1 个答案:

答案 0 :(得分:-1)

根据documentation of fputcsv function,它有一个默认的封闭值:“。将此设置为空白应该有助于您的事业。

我会说这应该有效:

//array in csv schreiben
$daten = array_filter($daten);
$csv_array[] = $daten;
$fp = fopen("golfDBtest.csv", 'w');

foreach ($csv_array as $fields) {
    fputcsv($fp, $fields, ",", "");
}
fclose($fp);