The code from this answer simply extracts the contents of a zip file to a folder:
<?php
$zip = new ZipArchive;
$res = $zip->open('file.zip');
if ($res === TRUE) {
$zip->extractTo('/myzips/extract_path/');
$zip->close();
echo 'woot!';
} else {
echo 'doh!';
}
?>
Is there any simple way (without a foreach loop, per file, and recursively descending into subfolders) to run this operation in reverse, in PHP, so that the original zip file is created again?
The "extract_path" folder must not be included in the zip file, which is why I can't simply use the recursive function linked above.
This would be the PHP equivalent of doing these linux shell commands, which are pretty simple:
cd /myzips/extract_path/
zip /dest/file.zip *
(before anyone comments "Why would you want to do that?", it's because I want to modify a file then recreate the zip file)