php 生成Tab键或逗号分隔的CSV
程序员文章站
2024-04-02 14:00:04
php 生成tab键或逗号分隔的csv的代码如下所示:
php 生成tab键或逗号分隔的csv的代码如下所示:
<?php header("content-type:text/csv;charset=utf-8"); header("content-disposition:attachment;filename=aa.csv"); header('cache-control:must-revalidate,post-check=0,pre-check=0'); header('expires:0'); header('pragma:public'); $data = "\xef\xbb\xbfaaaaa\tbbbbb\tccccc\n11111\t222222\t33333"; // \xef\xbb\xbf是bom头 $data = iconv('utf-8', 'ucs-2', $data); echo $data;
<?php header("content-type:text/csv;charset=utf-8"); header("content-disposition:attachment;filename=aa.csv"); header('cache-control:must-revalidate,post-check=0,pre-check=0'); header('expires:0'); header('pragma:public'); $data = "aaaaa,bbbbb,ccccc\n11111,222222,33333"; $data = iconv('utf-8', 'gbk', $data); echo $data;
以上所述是小编给大家介绍的php 生成tab键或逗号分隔的csv,希望对大家有所帮助
上一篇: php单例模式的简单实现方法