Skip to content

Instantly share code, notes, and snippets.

@cookpete
Last active August 29, 2015 13:56
Show Gist options
  • Save cookpete/9212216 to your computer and use it in GitHub Desktop.
Save cookpete/9212216 to your computer and use it in GitHub Desktop.
Super simple loading and saving of PHP data, with compression
function load($path){
return json_decode(uncompress(file_get_contents($path)));
}
function save($data, $path){
$fh = fopen($path, 'w');
fwrite($fh, compress(json_encode($data)));
fclose($fh);
}
function compress($string){
return gzdeflate($string, 9);
}
function uncompress($string){
return gzinflate($string);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment