gzfile()
gzfile() — Read entire gz-file into an array.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
What it does
This function is identical to readgzfile(), except that it returns the file in an array.
Signature
gzfile(string $filename, bool $use_include_path = false): array|false
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $filename | string | The file name. |
| $use_include_path | bool | If set to true, files in the include_path are searched for too. |
Return value
An array containing the file, one line per cell, empty lines included, and with newlines still attached, or false on failure.
Example
A runnable snippet:
$lines = gzfile('somefile.gz'); foreach ($lines as $line) { echo $line; }
Changelog
| Version | Change |
|---|---|
| 8.5.0 | use_include_path is now of type bool. Previously, it was of type int. |
See also
All PHP 8.5 built-in functions
Reference card built from the PHP manual page gzfile() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.