title: PHP Script to download files in zip
body: <p>I'm setting up a script on my server that uses some GET variables sent by a user to decides which files to include in a zip that then gets returned to the user. The ZIP file is created dynamically by the script and will always have the name myZip.zip.</p>
  
  <p>If I potentially have 100 users calling the script at the same time, and each user may have different files included in the zip, will this work? </p>
  
  <p>Thanks!</p>
  
  <p>example of script:</p>
  
  <pre><code>&lt;?php
  
       $fileA = 'fileA.xml';
       $fileB = 'fileB.xml';
       $fileC = 'fileC.xml';
  
       $filesToSend = array();
  
       if(conditionA) {
  
          array_push($filesToSend, $fileA);
       }
  
      if(conditionB) {
  
          array_push($filesToSend, $fileB);
       }
  
       if(conditionC) {
  
          array_push($filesToSend, $fileC);
       }
  
       if(count($filesToSend) &gt; 0) {
  
          $zipname = "myZip.zip";
          $zip = new ZipArchive();
          $res = $zip-&gt;open($zipname, ZipArchive::CREATE);
  
          if ($res === TRUE) {
  
              foreach ($filesToSend as $file) {
  
                  $zip-&gt;addFile($file);
              }
          }
          else {
  
              echo 'failed, code:' . $res;
          }
  
          $zip-&gt;close();
  
          header("Cache-Control: no-store, no-cache, must-revalidate");
          header("Cache-Control: post-check=0, pre-check=0", false);
          header("Pragma: no-cache");
          header("Content-type: application/zip");
          header('Content-length: '.filesize($zipname));
          header('Content-disposition: attachment; filename=' . basename($zipname));
          ob_clean();
          flush();
          readfile($zipname);
          @unlink($file);
      }
      else {
          echo "nothing new";
          echo $modifiedDate;
      }
  ?&gt;
  </code></pre>