Skip to content

Instantly share code, notes, and snippets.

@TheYkk
Last active November 17, 2018 09:29
Show Gist options
  • Save TheYkk/14906c4660a46a228bc156cb67abbd5d to your computer and use it in GitHub Desktop.
Save TheYkk/14906c4660a46a228bc156cb67abbd5d to your computer and use it in GitHub Desktop.
Zip all file from directory
<?php
function get_directory_list($dir = '*')
{
static $files = [];
foreach (glob($dir) as $file) {
if (is_dir($file)) get_directory_list($file . '/*');
else $files[] = $file;
}
return $files;
}
$files = get_directory_list('dosyalar/*');
$zip = new ZipArchive();
$zip->open('prototurk.zip', ZIPARCHIVE::CREATE);
foreach ($files as $file) {
$zip->addFile($file);
}
$zip->close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment