title: PHP - Compress a txt file while maintaining the file extension
body: <p>I want to compress a <code>.txt</code> file in PHP while maintaining the file extension. When I decompress the <code>.gz</code> file the extension (<code>.txt</code>) in the <code>.gz</code> file is removed. (<code>test.txt</code> becomes -> <code>test</code>)</p>
  
  <p>Here's a example of my PHP code to compress <code>test.txt</code> into a <code>.gz</code> file:</p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  
  // Name of the file we are compressing
  $file = "test.txt";
  
  // Name of the gz file we are creating
  $gzfile = "test.gz";
  
  // Open the gz file (w9 is the highest compression)
  $fp = gzopen ($gzfile, 'w9');
  
  // Compress the file
  gzwrite ($fp, file_get_contents($file));
  
  // Close the gz file and we are done
  gzclose($fp);
  
  ?&gt;
  </code></pre>
  
  <p>Does someone knows what I'm doing wrong? Or is this because <code>gzip</code> limations?</p>