Last active
August 29, 2015 13:56
-
-
Save cookpete/9212216 to your computer and use it in GitHub Desktop.
Super simple loading and saving of PHP data, with compression
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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