Look at the above snippet, here you can see a function called createZipAndDownload() which takes $files, $filesName, and $zipFileName as a parameter. To use this pretty function, first of all, create an array with the file name. And then pass that files array as the first argument of createZipAndDownload(). The second argument with being the directory path of these files and the third argument will be the name of zipping file.
// Files which need to be added into zip $files = array('sample.php', 'sample.jpg', 'sample.pdf', 'sample.doc'); // Directory of files $filesPath = '/ROOT/FILE_PATH'; // Name of creating zip file $zipName = 'document.zip'; echo createZipAndDownload($files, $filesPath, $zipName);