fputcsv插入额外"

时间:2017-07-04 10:47:00

标签: php csv encoding

我意识到包含空格的字符串会在csv文件中插入一个额外的"在开始和结束时

if (!file_exists("./csv/file.csv")) {
    $header = array("Arbol completo","Títol","Code","Parent Code","Servei","Urgència per defecte","Impacte","No es pot sol·licitar","Flux de Treball","SLA","Grup Resolutor-1","Grupo responsable catalogo","Informació","Documentació","Descripció","Llista autoritzats","Icona","Caracteristica", "Valor");
    $fp = fopen("./csv/catalogo_de _peticiones_de_servicio.csv", "w");
    fprintf($fp, $bom =( chr(0xEF) . chr(0xBB) . chr(0xBF)));
    fputcsv($fp, $header,";");
    fclose($fp);
}

它有点蠢蠢欲动,它难以解决我使用utf-8 charset的问题

1 个答案:

答案 0 :(得分:0)

将机箱指定为空白,这是fputcsv的第4个可选参数。默认机箱为"

fputcsv($fp, $header,";", '');

Reference Link