WordPress Function – Load Serialized Array from a Binary File
This function give you the convenience of reading serialized array from a binary file. It is good to manage few things with files instead of querying the database for very small flags which can be intelligently manged through filing.
if(!function_exists('load_binary_file'))
{
function load_binary_file($settings=array())
{
$binary_file_file = dirname(__FILE__).'/settings.dat';
if(file_exists($binary_file_file))
{
$data = file_get_contents($binary_file_file);
if($data!='')
{
if(is_array(unserialize($data)))
{
$data = unserialize($data);
$settings = array_merge($settings, $data);
}
}
}
return $settings;
}
}
Used in: WordPress Plugin – Keep Backup Daily
Last updated: March 19, 2014