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.

Advertisements

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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s