Load and save a array dump

Submitted by:Jhon Smith

Date added:01 July, 2015

Category:PHP

Loads and saves a compressed dump of an array

Tags: array , array dump

Code Snippet:

function load_array_dump($filename) {
$fp = fopen($filename,"r");
$content = fread($fp,filesize($filename));
fclose($fp);

eval('$array='.gzuncompress(stripslashes($content)).';');
return($array);
}

function save_array_dump($filename, $array) {
$dump = addslashes(gzcompress(var_export($array,true),9));
$fp = fopen($filename, "wb+");
fwrite($fp, $dump);
fclose($fp);
}

 
 

Comments