title: PHP Export CSV in UTF-8 for Excel
body: <p>I'm having trouble exporting CSV data that has non-latin characters.</p>
  
  <p>I am exporting the data as a CSV file using the following headers and PHP code:</p>
  
  <pre><code>    header("Content-type: text/csv; charset=utf-8");
      header("Content-Disposition: attachment; filename=myFile.csv");
      header("Pragma: no-cache");
      header("Expires: 0");
  
      echo "First Name,Last Name, Email Address\n";
      foreach ($users as $user) {
          echo "{$user['first_name']},{$user['last_name']},{$user['email']}\n";
      }
  </code></pre>
  
  <p>On Microsoft Excel, Since my data contains non-latin chars (Hebrew) I am seeing a scrambled data like this:</p>
  
  <p><a href="https://i.stack.imgur.com/yVU7j.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yVU7j.png" alt="enter image description here"></a></p>
  
  <p>This issue doesn't exists on LibreOffice. any ideas how can I make MS-Excel open the file correctly?</p>