phptext-compression

Compressing a string, end result without line breaks?


I'm trying to compress any given string to a shorter version, copy paste-able compressed string that doesn't contain any line breaks.

I tried gzcompress, but then copy/pasting the result into a different php script and trying to gzuncompress throws "Warning: gzuncompress(): data error"

Is there any native php function that compresses a string, and the result is a string without any line breaks?

Thanks.


Solution

  • You could try base64_encode / base64_decode. If you're compressing to binary for cut and paste, I would suggest you base64 encode it first.