用PHP输出一个csv文件
foreach ($old['lines'] as $line) { fputcsv($new, $line); }
比如$line的内容是:
CA,12,Y
MU,13,Y
MU,12,N
我希望的数据:
"CA","12","Y"
"MU","13","Y"
"MU","12","N"
我这样做
foreach ($lines as &$line) { foreach ($line as &$column) { $column = '"' . $column . '"'; } }
结果出来每一列数据上都被加了两个双引号:
""CA"",""12"",""Y""
""MU"",""13"",""Y""
""MU"",""12"",""N""
慕标琳琳
红糖糍粑