Note Submitter: Xardas der Dunkle
Reason: bad code
----
I have written a small Class in PHP5 for reading a ZIP-File:
I hope someone could need it.
<?php
class zip
{
public function readZIPFile($filename)
{
// Declair Vars
$i = 0;
$array = array();
$zip = zip_open($filename);
// Read ZIP and write it to an Array
if($zip):
while($entry = zip_read($zip)):
$array[$i]['name'] = zip_entry_name($entry);
$array[$i]['size'] =
zip_entry_filesize($entry);
$array[$i]['compressed'] =
zip_entry_compressedsize($entry);
$array[$i]['method'] =
zip_entry_compressionmethod($entry);
if(zip_entry_open($zip, $entry, "r")):
$array[$i]['content'] = zip_entry_read($entry,
zip_entry_filesize($entry));
zip_entry_close($entry);
endif;
$i++;
endwhile;
return $array;
else:
trigger_error("Zip-File couldn't be
open!",E_USER_ERROR);
return false;
endif;
}
}
?>
mfG Xardas
--
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php
|