0

Here is my PHP code:

<?php

header('Content-Type: application/excel');
header('Content-Disposition: attachment; filename="sample.csv"');

$data = array(
    'فرید',
    'علی'
);

$fp = fopen('php://output', 'w');
foreach ( $data as $line ) {
    $val = explode(",", $line);
    fputcsv($fp, $val);
}
fclose($fp);

and here is the output:

enter image description here

why فرید and علی looks vague in the export file? I don't know what ÙØ±ÛŒØ and علی even mean. anyway, does anybody know how can I fix it? In other word, how can I make a CSV export of an array which contains Persian characters?

stack
  • 10,280
  • 19
  • 65
  • 117
  • @JayBlanchard I seen that question before asking mine, but still I cannot solve the problem.. – stack Nov 07 '16 at 13:12
  • Consult [UTF-8 all the way through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through), it's more than likely the file's encoding. – Funk Forty Niner Nov 07 '16 at 13:18

0 Answers0