Note that there are some explanatory texts on larger screens.

plurals
  1. POEncoding accents csv - PHP
    primarykey
    data
    text
    <p>I've been looking through all the answers here and I haven't found the solution.</p> <p>Here's what I got:</p> <p>MySQL : Database &amp; Table encoding => <code>utf8_unicode_ci</code></p> <p>I'm trying to convert a an array (containing rows from a query) to CSV</p> <p>however when i open the csv I get this</p> <pre><code>Prénom </code></pre> <p>instead of </p> <pre><code>Prénom </code></pre> <p>here's my code</p> <pre><code>$allQueryRows = array(); while($row_query = $stmt_select-&gt;fetch(PDO::FETCH_ASSOC)){ $row_query = array_map("utf8_encode", $row_query); array_push($allQueryRows, $row_query); } download_send_headers("csv" . date("Y-m-d") . ".csv"); echo array2csv($allQueryRows); die(); function array2csv(array &amp;$array) { if (count($array) == 0) { return null; } ob_start(); $df = fopen("php://output", 'w'); fputcsv($df, array_keys(reset($array))); foreach ($array as $row) { fputcsv($df, $row); } fclose($df); return ob_get_clean(); } function download_send_headers($filename) { // disable caching $now = gmdate("D, d M Y H:i:s"); header("Expires: Tue, 03 Jul 2001 06:00:00 GMT"); header("Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate"); header("Last-Modified: {$now} GMT"); // force download header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); // disposition / encoding on response body header("Content-Disposition: attachment;filename={$filename}"); header("Content-Transfer-Encoding: binary"); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload