note 93090 modified in function.ziparchive-addfile by danbrown

From: Date: Sat, 22 Aug 2009 19:16:17 +0000
Subject: note 93090 modified in function.ziparchive-addfile by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-159789@lists.php.net to get a copy of this message
Here's a little extension to ZipArchive that handles directories recursively: <?php class Zipper extends ZipArchive { public function addDir($path) { print 'adding ' . $path . '<br>'; $this->addEmptyDir($path); $nodes = glob($path . '/*'); foreach ($nodes as $node) { print $node . '<br>'; if (is_dir($node)) { $this->addDir($node); } else if (is_file($node)) { $this->addFile($node); } } } } // class Zipper ?> --was-- <?php Here's a little extension to ZipArchive that handles directories recursively: class Zipper extends ZipArchive { public function addDir($path) { print 'adding ' . $path . '<br>'; $this->addEmptyDir($path); $nodes = glob($path . '/*'); foreach ($nodes as $node) { print $node . '<br>'; if (is_dir($node)) { $this->addDir($node); } else if (is_file($node)) { $this->addFile($node); } } } } // class Zipper ?> http://php.net/manual/en/function.ziparchive-addfile.php

« previous php.notes (#159789) next »