note 85302 added to function.ziparchive-addemptydir

From: Date: Sun, 24 Aug 2008 22:28:21 +0000
Subject: note 85302 added to function.ziparchive-addemptydir
Groups: php.notes 
Request: Send a blank email to php-notes+get-143798@lists.php.net to get a copy of this message
Here's a simple recurring function to add a directory, all sub-directories and all files to an already created zip file; <?php // Function to recursively add a directory, // sub-directories and files to a zip archive function addFolderToZip($dir, $zipArchive){ if (is_dir($dir)) { if ($dh = opendir($dir)) { //Add the directory $zipArchive->addEmptyDir($dir); // Loop through all the files while (($file = readdir($dh)) !== false) { //If it's a folder, run the function again! if(!is_file($dir . $file)){ // Skip parent and root directories if( ($file !== ".") && ($file !== "..")){ addFolderToZip($dir . $file . "/", $zipArchive); } }else{ // Add the files $zipArchive->addFile($dir . $file); } } } } } ?> Would be nice to see more input on these functions :) Dayjo ---- Server IP: 203.89.181.186 Probable Submitter: 131.203.76.50 ---- Manual Page -- http://www.php.net/manual/en/function.ziparchive-addemptydir.php Edit -- https://master.php.net/note/edit/85302 Del: integrated -- https://master.php.net/note/delete/85302/integrated Del: useless -- https://master.php.net/note/delete/85302/useless Del: bad code -- https://master.php.net/note/delete/85302/bad+code Del: spam -- https://master.php.net/note/delete/85302/spam Del: non-english -- https://master.php.net/note/delete/85302/non-english Del: in docs -- https://master.php.net/note/delete/85302/in+docs Del: other reasons-- https://master.php.net/note/delete/85302 Reject -- https://master.php.net/note/reject/85302 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#143798) next »