Example on how to read an entry from a ZIP archive (file "bar.txt" inside "./foo.zip"):
<?php
$fp = fopen('zip://./foo.zip#bar.txt', 'r');
if( $fp ){
while( !feof($fp) ){
echo fread($fp, 8192);
}
fclose($fp);
}
?>
Also, apparently, the "zip:" wrapper does not allow writing as of PHP/5.3.6. You can read http://php.net/ziparchive-getstream for further reference since the underlying code is probably the same.
zlib://
bzip2://
zip://
zlib:// -- bzip2:// -- zip:// — 圧縮ストリーム
説明
zlib: PHP 4.0.4 - PHP 4.2.3 (fopencookie をサポートするシステムのみ)
compress.zlib:// および compress.bzip2:// PHP 4.3.0以降
zlib: は gzopen() と同様に 動作しますが、このストリームは fread() および 他のファイルシステム関数と組み合わせて使用することができるところが 異なります。この機能ではファイル名に ':' 文字が含まれる曖昧さが あるため、PHP 4.3.0 以降では古い機能となっています。代わりに compress.zlib:// を使用してください。
compress.zlib:// および compress.bzip2:// は、それぞれ gzopen() および bzopen() と等価で、 fopencookie をサポートしないシステムの上でも動作します。
ZIP 拡張モジュール は zip: ラッパーを登録します。
オプション
- zlib:
- compress.zlib://
- compress.bzip2://
alvaro at demogracia dot com
12-Apr-2011 07:41
joshualross at gmail dot com
19-Aug-2007 12:24
I had a difficult time finding how to use compress.zlib with an http resource so I thought I would post what I found
<?php
$file = 'compress.zlib://http://www.example.com/myarchive.gz';
$fr = fopen($file, 'rb');
?>
Per the bugreport I found here (http://bugs.php.net/bug.php?id=29045)
