ConFoo Montreal 2026: Call for Papers

Voting

: max(six, zero)?
(Example: nine)

The Note You're Voting On

douglasjam at gmail dot com
7 years ago
Example about to use deflate functions to write a gzip encoded file in chunks.

<?php

$handler
= fopen('/tmp/test.csv', 'w');
$deflateContext = deflate_init(ZLIB_ENCODING_GZIP, ['level' => 9]);

$strings = [
'Hello, how are you?' . PHP_EOL,
'I am fine thanks' . PHP_EOL,
'Hello, how are you?' . PHP_EOL,
];

foreach (
$strings as $string) {
fwrite($handler, deflate_add($deflateContext, $string, ZLIB_NO_FLUSH));
}

fwrite($handler, deflate_add($deflateContext, '', ZLIB_FINISH));
fclose($handler);

echo
gzdecode(file_get_contents('/tmp/test.csv'));

<< Back to user notes page

To Top