search for in the  
<gzeofgzgetc>
Last updated: Thu, 19 May 2005

gzfile

(PHP 3, PHP 4, PHP 5)

gzfile -- Read entire gz-file into an array

Description

array gzfile ( string filename [, int use_include_path] )

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

Parameters

filename

The file name.

use_include_path

You can set this optional parameter to 1, if you want to search for the file in the include_path too.

Return Values

An array containing the file, one line per cell.

Examples

Example 1. gzfile() example

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



User Contributed Notes
gzfile
webmaster at ragnarokonline dot de
13-Jan-2004 01:58
This works similar to gzfile() but it returns the file in a string instead of an array and doesn't write it to stdout compared to readgzfile.

Note: unlike the usual file-functions filesize won't work here, since the length-parameter of gzread refers to the uncompressed length, while filesize returns the size of the compressed file.

<?php
function gzfile_get_contents($filename, $use_include_path = 0) {
  
$file = @gzopen($filename, 'rb', $use_include_path);
   if (
$file) {
      
$data = '';
       while (!
gzeof($file)) {
          
$data .= gzread($file, 1024);
       }
      
gzclose($file);
   }
   return
$data;
}
?>

<gzeofgzgetc>
 Last updated: Thu, 19 May 2005
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: The Server Pages
Last updated: Thu May 19 17:35:34 2005 CDT