gzfile

(PHP 4, PHP 5)

gzfile — Считывает весь gz-файл в массив

Описание

array gzfile ( string $filename [, int $use_include_path ] )

Аналогична readgzfile(), но возвращает файл, разбитый построчно на массив.

Список параметров

filename

Имя файла.

use_include_path

Если вы хотите, чтобы файл также искался в директориях include_path, установите значение этого аргумента в 1.

Возвращаемые значения

Массив строк файла.

Смотрите также

Коментарии

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($file1024);
        }
       
gzclose($file);
    }
    return 
$data;
}
?>
2004-01-13 13:58:30
http://php5.kiev.ua/manual/ru/function.gzfile.html
Автор:
A quicker way to load a gziped file in a string :
<?php
function gzfile_get_contents($filename$use_include_path 0)
{
   
//File does not exist
   
if( !@file_exists($filename) )
    {    return 
false;    }
   
   
//Read and imploding the array to produce a one line string
   
$data gzfile($filename$use_include_path);
   
$data implode($data);
   return 
$data;
}
?>
2005-06-28 09:44:44
http://php5.kiev.ua/manual/ru/function.gzfile.html
In PHP4.4.1 I noticed that gzfile only reads up to 8190 bytes per line. I had a 20K SQL query that was cut into 3 parts - and wondered why the SQL server complained. 

Reading an uncompressed file with the file() command works as expected.
2005-11-27 06:12:47
http://php5.kiev.ua/manual/ru/function.gzfile.html
This function is not binary safe. (intentionally, or not, that's the question :)
2008-11-21 12:11:29
http://php5.kiev.ua/manual/ru/function.gzfile.html

    Поддержать сайт на родительском проекте КГБ