Skip to content

Instantly share code, notes, and snippets.

@chluehr
Created November 28, 2011 08:46
Show Gist options
  • Save chluehr/1399660 to your computer and use it in GitHub Desktop.
Save chluehr/1399660 to your computer and use it in GitHub Desktop.
PHP encode and compress
<?php
/* by pablo at compuar dot com see http://php.net/manual/de/function.base64-encode.php
*
*
*/
$string = 'Blah';
$encoded = strtr(base64_encode(addslashes(gzcompress(serialize($string),9))), '+/=', '-_,');
$string= unserialize(gzuncompress(stripslashes(base64_decode(strtr($encoded, '-_,', '+/=')))));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment