开发者

Opening GZ Object with PHP

开发者 https://www.devze.com 2023-02-18 13:49 出处:网络
I haven\'t found similar queries, so quick question. Can you use any GZIP functions or such with PHP to read a GZIP object.

I haven't found similar queries, so quick question. Can you use any GZIP functions or such with PHP to read a GZIP object.

I'm basically using Amazon S3 class to get the .GZ logs, and I'm trying to parse whilst it's a loaded object, as opposed to downloading it to local and then parsing.

Is this not possible? Should I only be trying to download and 开发者_运维问答parse?


With Zlib extension (http://php.net/manual/en/book.zlib.php) you can open and write gzip compressed files on the fly.

You need to save gz file and open it with gzfile() function.

Like this

$file = gzfile('log.gz');
foreach ($file as $line) {
    // read it line by line
}
0

精彩评论

暂无评论...
验证码 换一张
取 消