I have the following function that creates an array from data and later creates a zip file in script however in php 7 and above it doesn't function. Does the following snippet have a depricated array function? function zipFilesAndDownload($file_names,$archive_file_name,$file_path)
{
$zip = new ZipArchive();
//create the file and throw the error if unsuccessful
if ($zip->open($archive_file_name, ZIPARCHIVE::CREATE )!==TRUE) {
exit("cannot open <$archive_file_name>\n");
}
//add each files of $file_name array to archive
foreach($file_names as $files)
{
$zip->addFile($file_path.$files,$files);
//echo $file_path.$files,$files."<br />";
}
unset($files);
$zip->close();
//then send the headers to foce download the zip file
header("Content-type: application/zip");
header("Content-Disposition: attachment; filename=$archive_file_name");
header("Pragma: no-cache");
header("Expires: 0");
readfile("$archive_file_name");
exit;
}
___________________________end function
//create an empty array
$file_names = array();
//fetch the names from database
while($row = mysqli_fetch_array($result2))
{
//Add the values to the array
//Below 8 ,eams the the number of the mysql table column
$file_names[] = $row[filename];
}
__________________________call function
//cal the function
zipFilesAndDownload($file_names,$archive_file_name,$file_path);