thinkphp csv.class.php文件导出gb2312格式csv
Posted 人在征途1
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了thinkphp csv.class.php文件导出gb2312格式csv相关的知识,希望对你有一定的参考价值。
1 function creatcsv($filename,$array) 2 { 3 @ini_set(‘display_errors‘, 0); 4 header("Content-Disposition: attachment; filename=$filename.csv"); 5 header("Content-Transfer-Encoding: binary"); 6 header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 7 header("Pragma: no-cache"); 8 header("Expires: 0"); 9 header(‘application/txt;charset=gb2312‘); 10 header( ‘Content-Transfer-Encoding: binary‘ ); 11 ob_clean(); 12 //echo chr(0xFF).chr(0xFE); 13 if(is_array($array)) 14 { 15 if(is_array(@$array[0])) 16 { 17 foreach ($array as $tmp) 18 { 19 echo $this->est_iconv($this->charset, ‘gb2312‘,‘"‘.join(‘","‘,$tmp).‘"‘); 20 echo "\r\n"; 21 } 22 } 23 else 24 { 25 echo $this->est_iconv($this->charset, ‘gb2312‘, join(‘,‘,$array)); 26 } 27 } 28 else 29 { 30 $this->ErrorMsg("param is not array"); 31 return false; 32 } 33 }
以上是关于thinkphp csv.class.php文件导出gb2312格式csv的主要内容,如果未能解决你的问题,请参考以下文章