Add special characters to CSV export in PHP

Description:

When exporting data to CSV, the special characters are not displayed, as the ending ; is treated as a new column.

Solution:

Check the encoding of the CSV file. Make sure this is utf-8.

However, in some cases this will not work regardless. Make sure you echobefore the last line of export the following string:

echo “\xEF\xBB\xBF”;

 

In other cases the fputcsv(); function of PHP might work, specifying the delimiter and the encoding.

About admin

Just another php developer trying to give something back to the community.
This entry was posted in PhP, Tools and tagged , , , . Bookmark the permalink.

Leave a comment