I want to try write Persian character in CSV file in PHP, I am using fputcsv
function but how can write UTF-8 character to CSV file with fputcsv
?
Part of my code:
$df = fopen($filepath, 'w');
fputcsv($df, array($coupon->code, $discount->label));
Try this also:
If you want make a UTF-8 file for excel, use this simple solution:
See the original answer here on the official PHP page.
Try this:
the line
fprintf($df, chr(0xEF).chr(0xBB).chr(0xBF));
writes file header for correct encoding.