ฟังก์ชันอ่านไฟล์ซิป zip_entry_read()
ความหมายของฟังก์ชันและการใช้งาน
อ่านไฟล์ต่างๆที่อยู่ในไฟล์ zip ด้วยฟังก์ชัน zip_entry_read()
รูปแบบการเขียน (Syntax)
zip_entry_read(zip_entry,length)
- zip_entry คือ resource ที่ได้จากฟังก์ชัน zip_read()
- length คือ ความยาวที่ต้องการอ่านหน่วยเป็น byte (Default คือ 1024)
ตัวอย่าง
<?php
$filezip = zip_open("file.zip");
if ($filezip)
{
while ($zip_entry = zip_read($filezip))
{
echo "<p>";
echo "Name: " . zip_entry_name($zip_entry) . "<br />";
if (zip_entry_open($filezip, $zip_entry))
{
echo "File Contents:<br/>";
$contents = zip_entry_read($zip_entry);
echo "$contents<br />";
zip_entry_close($zip_entry);
}
echo "</p>";
}
zip_close($filezip);
}
?>
Name: ziptest.txt
File Contents:
Hello World! This is a test for a the zip functions in PHP.
Name: htmlziptest.html
File Contents:
Hello World!
This is a test for a the zip functions in PHP.