PHP zip_entry_read() 関数


❮ 完全な PHP Zip ファイル・リファレンス

定義と用法

zip_entry_read() 関数は、オープンしているzipアーカイブエントリからコンテンツを取得します。

この関数は、成功した場合はエントリの内容を返し、失敗した場合はFALSEを返します。

構文

zip_entry_read(zip_entry,length)

パラメータ 説明
zip_entry 必須。読み込む zip エントリ・リソースを指定する(zip_read()でオープンしたzipエントリ)
length 任意。返されるバイト数を指定する(圧縮されていないサイズ)。デフォルトは 1024

<?php
$zip = zip_open("test.zip");

if ($zip)
  {
  while ($zip_entry = zip_read($zip))
    {
    echo "<p>";
    echo "Name: " . zip_entry_name($zip_entry) . "<br />";

    if (zip_entry_open($zip, $zip_entry))
      {
      echo "File Contents:<br/>";
      $contents = zip_entry_read($zip_entry);
      echo "$contents<br />";
      zip_entry_close($zip_entry);
      }
    echo "</p>";
  }

zip_close($zip);
}
?>

output of the code depends on the contents of the zip archive:

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.

❮ 完全な PHP Zip ファイル・リファレンス