Mick Mick - 1 year ago 122
PHP Question

Zip multiple files with Zend Filter Compress

Is there a way to zip multiple files in one zip archive using Zend_Filter_Compress class ?

The official documentation only talks about one file or one folder.

Using an array as an argument for the calling method doesn't work, as the archive contains only the last file in the array.

$filter = new Zend_Filter_Compress(array(
'adapter' => 'Zip',
'options' => array(
'archive' => 'test.zip'
$compressed = $filter->filter($b);

Answer Source

As far as i know Zend_Filter_Compress supports only strings, single files or folders (inclusive sub-folders) for compression.

But you can create the archive by using the ZipArchive class.

See: http://www.php.net/manual/de/class.ziparchive.php

$files = array('a.txt', 'b.txt', 'c.txt');
$zip = new ZipArchive();
$zip->open('archive.zip', ZipArchive::CREATE);
foreach ($files as $file) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download