title: zip file with php - exclude the folder
body: <p>I have one zip function, and i want each file inside FOLDER to zip</p>
  
  <p>So, the path is:</p>
  
  <p>public_html/form/FOLDER/file_to_zip.xml</p>
  
  <p>As you can see in the code bellow, the $files_to_zip array has the "FOLDER/file_to_zip.xml" path and whenever it zips, also zips the folder, i only want the file to get zipped.</p>
  
  <p>What can i do here?</p>
  
  <pre><code>function create_zip($files = array(),$destination = '',$overwrite = true) {
  
      $valid_files = array();
      if(is_array($files)) {
          foreach($files as $file) {
              if(file_exists($file)) {
                  $valid_files[] = $file;
              }
          }
      }
      if(count($valid_files)) {
          $zip = new ZipArchive();
          if($zip-&gt;open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {
              return false;
          }
          foreach($valid_files as $file) {
              $zip-&gt;addFile($file,$file);
          }
  
          $zip-&gt;close();
  
          return file_exists($destination);
      }
      else
      {
          return false;
      }
  }
  
  $loja=$_GET['loja'];
  
  $connect = new MySQL('localhost','iloja_phc','sexparade');
  $connect-&gt;Database('iloja_phc');
  $posts = $connect-&gt;Fetch('ipad');
  
  if ($posts &amp;&amp; mysql_num_rows($posts) &gt; 0) {
       echo "Nome  -  ID  -  Email:&lt;BR&gt;";
       while ($record = mysql_fetch_array($posts)) {
      $files_to_zip = array($loja.'/CL'.$record['rand'].'.xml');
      $result = create_zip($files_to_zip,'CL'.$record['rand'].'.zip');
           echo "&lt;a href='/formulario/CL".$record['rand'].".zip'&gt;".$record['nome']."&lt;/a&gt; - ".$record['id']." - EMAIL: ".$record['email']."&lt;/br&gt;";
       }
  } else {
       echo "Erro! Algo correu mal...";
  }
  </code></pre>