note 79057 added to ref.zip

From: Date: Thu, 08 Nov 2007 13:39:22 +0000
Subject: note 79057 added to ref.zip
Groups: php.notes 
Request: Send a blank email to php-notes+get-132112@lists.php.net to get a copy of this message
Heres a function I wrote that will extract a zip file with the same directory structure... Enjoy: <?php function unzip($zipfile) { $zip = zip_open($zipfile); while ($zip_entry = zip_read($zip)) { zip_entry_open($zip, $zip_entry); if (substr(zip_entry_name($zip_entry), -1) == '/') { $zdir = substr(zip_entry_name($zip_entry), 0, -1); if (file_exists($zdir)) { trigger_error('Directory "<b>' . $zdir . '</b>" exists', E_USER_ERROR); return false; } mkdir($zdir); } else { $name = zip_entry_name($zip_entry); if (file_exists($name)) { trigger_error('File "<b>' . $name . '</b>" exists', E_USER_ERROR); return false; } $fopen = fopen($name, "w"); fwrite($fopen, zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)), zip_entry_filesize($zip_entry)); } zip_entry_close($zip_entry); } zip_close($zip); return true; } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 212.116.219.76 (proxied: 86.60.88.89) ---- Manual Page -- http://www.php.net/manual/en/ref.zip.php Edit -- https://master.php.net/note/edit/79057 Del: integrated -- https://master.php.net/note/delete/79057/integrated Del: useless -- https://master.php.net/note/delete/79057/useless Del: bad code -- https://master.php.net/note/delete/79057/bad+code Del: spam -- https://master.php.net/note/delete/79057/spam Del: non-english -- https://master.php.net/note/delete/79057/non-english Del: in docs -- https://master.php.net/note/delete/79057/in+docs Del: other reasons-- https://master.php.net/note/delete/79057 Reject -- https://master.php.net/note/reject/79057 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#132112) next »