PHP 8.5.0 RC 2 available for testing

ZipArchive::getStreamIndex

(PHP 8 >= 8.2.0, PECL zip >= 1.20.0)

ZipArchive::getStreamIndex โ€” Get a file handler to the entry defined by its index (read only)

่ฏดๆ˜Ž

public ZipArchive::getStreamIndex(int $index, int $flags = 0): resource|false

Get a file handler to the entry defined by its index. For now, it only supports read operations.

ๅ‚ๆ•ฐ

index

Index of the entry

flags

If flags is set to ZipArchive::FL_UNCHANGED, the original unchanged stream is returned.

่ฟ”ๅ›žๅ€ผ

Returns a file pointer (resource) on success ๆˆ–่€…ๅœจๅคฑ่ดฅๆ—ถ่ฟ”ๅ›ž false.

็คบไพ‹

็คบไพ‹ #1 Get the entry contents with fread() and store it

<?php
$contents
= '';
$z = new ZipArchive();
if (
$z->open('test.zip')) {
$fp = $z->getStreamIndex(1, ZipArchive::FL_UNCHANGED);
if(!
$fp) die($z->getStatusString());

echo
stream_get_contents($fp);

fclose($fp);
}
?>

ๅ‚่ง

๏ผ‹ๆทปๅŠ ๅค‡ๆณจ

็”จๆˆท่ดก็Œฎ็š„ๅค‡ๆณจ

ๆญค้กต้ขๅฐšๆ— ็”จๆˆท่ดก็Œฎ็š„ๅค‡ๆณจใ€‚
To Top