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?
for ($i = 1; $i < 4; $i++) {
// for the 3 months of this year
$absolutepath = "$year_path/0$i";
if (file_exists($absolutepath) && 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 ???