thinkphp csv.class.php file Export gb2312 format CSV

Source: Internet
Author: User

1 function Creatcsv ($filename, $array)2     {3@ini_set ('display_errors',0);4Header"content-disposition:attachment; filename= $filename. csv");5Header"content-transfer-encoding:binary"); 6Header"cache-control:must-revalidate, post-check=0, pre-check=0");7Header"Pragma:no-cache");8Header"expires:0");9Header'application/txt;charset=gb2312');TenHeader'content-transfer-encoding:binary' ); one Ob_clean (); a         //Echo chr (0xFF). chr (0xFE); -         if(is_array ($array)) -         { the             if(is_array (@ $array [0])) -             { -                 foreach($array as$tmp) -                 { +echo $ this->est_iconv ($ this->charset,'gb2312','"'. Join ('","', $tmp).'"'); -Echo"\ r \ n"; +                 } a             } at             Else -             { -echo $ this->est_iconv ($ this->charset,'gb2312', Join (',', $array)); -             } -         } -         Else in         { -$ this->errormsg ("param is not an array"); to             return false; +         } -}

thinkphp csv.class.php file Export gb2312 format CSV

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.