zlib_encode

Compress data with the specified encoding

&reftitle.description; ``string``false```zlib_encode` `string` `data` `int` `encoding` `int` `level`-1

Compress data with the specified encoding.

&warn.undocumented.func;
&reftitle.parameters;

`data`

- The data to compress.

`encoding`

- The compression algorithm. Either `ZLIB_ENCODING_RAW`, `ZLIB_ENCODING_DEFLATE` or `ZLIB_ENCODING_GZIP`.

`level`

&reftitle.returnvalues;

&reftitle.examples;

### `zlib_encode` example

    <?php
    $str = 'hello world';
    $enc = zlib_encode($str, ZLIB_ENCODING_DEFLATE);
    echo bin2hex($enc);
    ?>

&example.outputs;

    789ccb48cdc9c95728cf2fca4901001a0b045d

&reftitle.seealso;

- `zlib_decode`