Created
August 10, 2017 07:54
-
-
Save HugoWen/2e866acc97daac6b217f1ed12934c494 to your computer and use it in GitHub Desktop.
php export csv file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function exportCSV($filename, $data) | |
{ | |
header('Content-Encoding: UTF-8'); | |
header('Content-type: text/csv; charset=UTF-8'); | |
header("Content-Disposition:attachment;filename=".$filename); | |
header('Cache-Control:must-revalidate,post-check=0,pre-check=0'); | |
header('Expires:0'); | |
header('Pragma:public'); | |
echo "\xEF\xBB\xBF"; // UTF-8 BOM | |
echo $data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment