Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> PHP

Hàm zip_read() trong PHP

Mô tả

Hàm zip_read() đọc entry (mục) tiếp theo trong một file ZIP archive.

Cú pháp

zip_read(zip)

Tham số

  • zip − Resource ZIP từ zip_open().

Giá trị trả về

Trả về resource chứa file trong archive nếu thành công.

Ví dụ

Giả sử file "new.zip" chứa: amit.txt, peter.txt, result.html, demo.java, settings.ini

<?php
$zip = zip_open("new.zip");
if ($zip) {
    while ($zip_entry = zip_read($zip)) {
        echo "File Name = " . zip_entry_filename($zip_entry) . "<br/>";
    }
    zip_close($zip);
}
?>

Kết quả

File Name = amit.txt
File Name = peter.txt
File Name = result.html
File Name = demo.java
File Name = settings.ini