Php compression and decompression of strings. Php compression and decompression of strings This article describes how to compress and decompress strings in php. Share it with you for your reference. The following php code uses gzcompr php to compress and decompress strings:
This document describes how to compress and decompress strings in php. Share it with you for your reference. The details are as follows:
The following php code uses gzcompress and gzuncompress to compress and decompress strings. you can set the compression level.
$ Str = 'Hello I am a very long string'; $ compressed = gzcompress ($ str, 9 ); // the compression level is 9 $ uncompressed = gzuncompress ($ compressed); echo $ str, "\ n"; echo $ uncompressed, "\ n"; echo base64_encode ($ compressed ), "\ n"; echo bin2hex ($ compressed), "\ n"; echo urlencode ($ compressed), "\ n ";
I hope this article will help you with php programming.
Examples in this article describes how to compress and decompress strings in php. Share it with you for your reference. The following php code uses gzcompr...