{% else-1 %}
мини-класс для работы с zip архивами. Писал сам когда то

                        
<?php

//Zipper.class.php//

class Zipper {
private $_files = array(),
$_zip;

public function __construct() { // вызываем класс архиватора
$this->_zip = new ZipArchive;
}

public function add($input) {
if (is_array($input)) { // если добавляем несколько файлов
$this->_files = array_merge($this->_files, $input);
} else { // добавление одного файла
$this->_files[] = $input;
}
}

public function store($location = null) {
if (count($this->_files) && $location) { // если есть файлы, и правильный путь, где будет создан новый архив
foreach ($this->_files as $index => $file) { // удаляем файлы с не верными путями
if (!file_exists($file)) {
unset($this->_files[$index]);
}
}

if ($this->_zip->open($location, file_exists($location) ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE)) { // создаем архив
foreach ($this->_files as $file) { // добаляем в архив файлы
$this->_zip->addFile($file, $file);
}

$this->_zip->close(); // закрывем архив
}
}
}
}
?>

Пример использования
$zip = new Zipper;

$zip->add(array('files/1.txt', 'files/2.txt', 'files/3.txt', 'files/4.txt')); // добавление файлов в архив

$zip->store('files/archiv.zip'); // создание архива
0 23 0
Без комментариев...