PHP zip_entry_read()関数
完全版 PHP Zip File リファレンスマニュアル
定義と使用法
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);
}
?>
$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);
}
?>
コードの出力は zip アーカイブの内容によって異なります:
Name: ziptest.txt
File Contents:
Hello World! This is a test for a the zip functions in PHP.
Name: htmlziptest.html
File Contents:
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 File リファレンスマニュアル 他の拡張モジュール