Skip to content

Instantly share code, notes, and snippets.

@kulikov
Created August 9, 2011 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kulikov/1134589 to your computer and use it in GitHub Desktop.
Save kulikov/1134589 to your computer and use it in GitHub Desktop.
php zip archive functions
<?php
function zip($sourceDir, $targetZipFileName)
{
$zip = new ZipArchive();
$zip->open($targetZipFileName, ZipArchive::CREATE);
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($sourceDir));
foreach ($iterator as $key => $value) {
$zip->addFile(realpath($key), $key);
}
$zip->close();
return $targetZipFileName;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment