title: PHP - How to save text file with ANSI encoding?
body: <p>I'm doing:</p>
  <pre><code>file_put_contents(&quot;txt/myfile.txt&quot;, $fileContents);
  </code></pre>
  <p>I have tried many ways to force my text file to be ANSI, like:</p>
  <pre><code>$fileContents = mb_convert_encoding($fileContents , mb_detect_encoding($fileContents , mb_detect_order(), true), 'WINDOWS-1252');
  </code></pre>
  <p>I have also tried:</p>
  <pre><code>$fileContents = iconv(&quot;ISO-8859-1&quot;, &quot;WINDOWS-1252&quot;, $fileContents );
  </code></pre>
  <p>I need ANSI because the text file should look nice when I open it with the &quot;type&quot; command from MS-DOS (cmd.exe in Windows 7)</p>
  <p>If I open my current file I can see the UTF-8 BOM:</p>
  <blockquote>
  <p>C:\Users\XXX&gt;type C:\myfile.txt</p>
  <p>´╗┐V017666999  00000000000000005350005122013</p>
  </blockquote>
  <p>If I open the file with Notepad++ and apply &quot;Convert to ANSI&quot; I get (what I need):</p>
  <blockquote>
  <p>C:\Users\XXX&gt;type C:\myfile.txt</p>
  <p>V017666999  00000000000000005350005122013</p>
  </blockquote>
  <p>Is there any way I can fix this? Thanks in advance.</p>