Created
October 14, 2016 23:49
-
-
Save Clivern/56fd7bfc1db0caded1e7bfd2a40e481f to your computer and use it in GitHub Desktop.
CSV With UTF-8 Support
This file contains hidden or 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
$results = [ | |
['اسم المستخدم', 'اسم المستخدم', 'اسم المستخدم'], | |
[5,8,6], | |
[5,8,7], | |
[2,3,5] | |
]; | |
header('Content-Encoding: UTF-8'); | |
header('Content-type: text/csv; charset=UTF-8'); | |
header('Content-Disposition: attachment; filename=sss.csv'); | |
echo "\xEF\xBB\xBF"; // UTF-8 BOM | |
// create a file pointer connected to the output stream | |
$output = fopen('php://output', 'w'); | |
// output the column headings | |
fputcsv($output, $results[0]); | |
unset($results[0]); | |
foreach ($results as $row) { | |
fputcsv($output, $row); | |
} | |
die(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment