title: How do I extract files without folder structure using tar
body: <p>I have a tar.gz-file with the following structure:</p>
  
  <pre><code>folder1/img.gif
  folder2/img2.gif
  folder3/img3.gif
  </code></pre>
  
  <p>I want to extract the image files without the folder hierarchy so the extracted result looks like:</p>
  
  <pre><code>/img.gif
  /img2.gif
  /img3.gif
  </code></pre>
  
  <p>I need to do this with a combination of Unix and PHP. Here is what I have so far, it works to extract them to the specified directory but keeps the folder hierarchy:</p>
  
  <pre><code>exec('gtar --keep-newer-files -xzf images.tgz -C /home/user/public_html/images/',$ret);
  </code></pre>