PHP Streaming CSV always adds UTF-8 BOM

前端 未结 2 1574
故里飘歌
故里飘歌 2021-01-22 11:39

The following code gets a \'report line\' as an array and uses fputcsv to tranform it into CSV. Everything is working great except for the fact that regardless of the charset I

2条回答
  •  一个人的身影
    2021-01-22 12:10

    I don't know if this solves your problem but have you tried using the print and implode functions to do the same thing?

    header("Content-type: text/csv; charset=iso-8859-1");
    header("Cache-Control: no-store, no-cache");
    header("Content-Disposition: attachment; filename=\"report.csv\"");
    
    for($i = 0; $i < $report->rowCount; $i++) {
        print(implode(',',$report->getTaxMatrixLineValues($i)));
    }
    

    That's not tested but pretty obvious.

提交回复
热议问题