PHP and Excel: UTF-8 Encoding Problem on CSV


Were we having a problem encoding a CSV to UTF-8, it was loading in the crazy characters.  We tried adding BOM to the file first before we did all the ‘fputcsv’ and it worked.  Hope it works for you too!

$fp = fopen($filename, 'w');
fwrite($fp, "xEFxBBxBF");