note 99326 deleted from function.ziparchive-extractto by danbrown

From: Date: Wed, 11 Aug 2010 00:51:43 +0000
Subject: note 99326 deleted from function.ziparchive-extractto by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-171559@lists.php.net to get a copy of this message
Note Submitter: Rafael Chaves Freitas ---- this function is based on one of the above functions and adds the overwrite option. <?php function unzipFileTo($zippedFilePath, $destinationPath, $overwrite = true){ if (file_exists($zippedFilePath)) { $files = array(); $zip = new ZipArchive; if ($zip->open($zippedFilePath) === TRUE) { for($i = 0; $i < $zip->numFiles; $i++) { $entry = $zip->getNameIndex($i); if ($overwrite || (substr( $entry, -1 ) != '/' && !file_exists($destinationPath.$entry))){ $files[] = $entry; } } $zip->extractTo($destinationPath, $files); $zip->close(); return TRUE; } else { return FALSE; } } else { return FALSE; } } ?>

« previous php.notes (#171559) next »