add_recurse_folder($dir . $file . '/', $zipdir . $file . '/'); } } else { // Add the files $this->addFile($dir . $file, $zipdir . $file); $filenct +=1; } } //Add the directory when folder was empty if( (!empty($zipdir)) && ($filenct==0)) { // remove directory separator before addEmptyDir // otherwhisen create double folder in zip $this->addEmptyDir(substr($zipdir, 0, -1)); } } } } }