php8.5
Home/ Manual/ zlib / functions/ gzfile

gzfile

PHP function Edit on GitHub ✎

(PHP 4, PHP 5, PHP 7, PHP 8)

Read entire gz-file into an array

Description

gzfile(string $filename, bool $use_include_path = false): array|false

This function is identical to readgzfile(), except that it returns the file in an array.

Parameters

filename

The file name.

use_include_path

If set to true, files in the include_path are searched for too.

Return Values

An array containing the file, one line per cell, empty lines included, and with newlines still attached, Falseforfailure.

Changelog

VersionDescription
8.5.0use_include_path is now of type bool. Previously, it was of type int.

Examples

gzfile() example

php
<?php
$lines = gzfile('somefile.gz');
foreach ($lines as $line) {
    echo $line;
}
?>

See Also

Source: reference/zlib/functions/gzfile.xml · from the official PHP manual (php/doc-en)