title: How create recursively ZIP file, from array which contains total directory paths WITHOUT the name of the pdfs inside
body: <p>I have a directory with name 2019. I want to create a ZIP file which contains all the pdf files inside the folders 01-03. In a for loop, I fill an array with all the paths of the directories who are not empty. Now I don't know how to open a stream or something else to put the array values inside in a for loop and recursively add all pdfs under each subfolder path inside it. Any idea guys?</p>
  
  <pre><code>for ($i = 1; $i &lt; 4; $i++) {
        // for the 3 months of this year
        $absolutepath = "$year_path/0$i";
        if (file_exists($absolutepath) &amp;&amp; glob($absolutepath . "/*")) {
            // check if path/year/month exists
            // check if folder contains any files
            // store specific full paths inside array for use
            array_push($path_array, $absolutepath);
            }
  } 
  // how can i put here $path_array into a function to create zip file which contains all the pdfs under each subfolder path of the $path_array ???
  </code></pre>