Load and save a array dump

Loads and saves a compressed dump of an array

function load_array_dump($filename) {
    $fp = fopen($filename,"r");
    $content = fread($fp,filesize($filename));
function save_array_dump($filename, $array) {
    $dump = addslashes(gzcompress(var_export($array,true),9));
    $fp = fopen($filename, "wb+");
    fwrite($fp, $dump);
Snippet Details

save_array_dump('test.txt', array(1,2,3));

Sorry folks, comments have been deactivated for now due to the large amount of spam.

Please try to post your questions or problems on a related programming board, a suitable mailing list, a programming chat-room,
or use a QA website like stackoverflow because I'm usually too busy to answer any mails related
to my code snippets. Therefore please just mail me if you found a serious bug... Thank you!

Older comments:

bayram May 10, 2010 at 13:20
Mohamed December 14, 2008 at 14:12
$el_file = "el_array.txt";

$el_array = load_array_dump($el_file);

echo "<pre>El array :n";

zenk September 09, 2008 at 05:16
O,it's very goooood function.