Skip to content

Instantly share code, notes, and snippets.

@TheYkk

TheYkk/zip.php

Last active Nov 17, 2018
Embed
What would you like to do?
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