title: BOM or \xFF\xFE displays &#65279; in csv file
body: <p>Need to convert array to display in csv file</p>
  
  <p>Here is sample code</p>
  
  <pre><code>$output=array(
  array('firstname' =&gt; 'latviešu', 'lastname' =&gt; 'Johnson', 'age' =&gt; 25),
  array('firstname' =&gt; 'русский', 'lastname' =&gt; 'latviešu', 'age' =&gt; 25),
  array('firstname' =&gt; 'šAmanda', 'lastname' =&gt; 'Miller', 'age' =&gt; 18),
  array('firstname' =&gt; 'english', 'lastname' =&gt; 'русский', 'age' =&gt; 25.04),
  );
  
  header('Pragma: public');
  header('Content-type: application/x-msexcel'); 
  header('Content-Disposition: attachment;  filename="utf8_bom.xls"');
  
  foreach($output as $row) {
  $implode = (implode("\t", $row)). "\r\n" ;
  $implode = mb_convert_encoding($implode, 'UTF-16LE', 'UTF-8'); 
  echo $implode = "\xFF\xFE" . $implode;
  }
  </code></pre>
  
  <p>csv output is like this</p>
  
  <p><img src="https://i.stack.imgur.com/YjElr.gif" alt="enter image description here"></p>
  
  <p>As you see starting from the second row there is character before each word. When I copied the character in html get <code>&amp;#65279;</code>.</p>
  
  <p>If remove <code>\xFF\xFE</code>, no such character, but the text is not normally readable. Tried to <code>trim</code>, but also not normally readable.</p>
  
  <p>How to remove that character?</p>
  
  <p><strong>Solution</strong></p>
  
  <p>Here is solution finally</p>
  
  <pre><code>foreach($output as $row) {
  if(!$flag) {
  $implode = (implode("\t", array_keys($row))). "\r\n" ;
  $implode = mb_convert_encoding($implode, 'UTF-16LE', 'UTF-8'); 
  echo $implode = "\xFF\xFE" . $implode;
  $flag = true;
  }
  $implode = (implode("\t", array_values($row))). "\r\n" ;
  $implode = mb_convert_encoding($implode, 'UTF-16LE', 'UTF-8'); 
  echo $implode;
  }
  </code></pre>
  
  <p>But next question related with the code... </p>
  
  <p>At the end of the array <code>array('firstname' =&gt; 'english', 'lastname' =&gt; 'русский', 'age' =&gt; 25.04),</code> is <code>25.04</code>; however in csv get <code>25.Apr</code></p>
  
  <p>how to fix this problem?</p>