note 60584 deleted from function.unserialize by aharvey
| From: | aharvey@php.net | Date: | Tue, 06 Nov 2012 01:25:48 +0000 |
| Subject: | note 60584 deleted from function.unserialize by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191696@lists.php.net to get a copy of this message | ||
Note Submitter: artistan at cableone dot net
----
// thanks to user comments I created this
/**
UnSerialize and return data
@param string [$serialized_data] data to unserialize
@return mixed
*/
function unserialize_data($serialized_data,$objects=true){
if($objects){
// thanks to comment from veg@rd.no 04-Jan-2006 10:34 at http://us2.php.net/manual/en/function.unserialize.php
// make classes for those that do not exist
$matches = Array();
preg_match_all('/O:(\d)*:"([^":]*)":/', $text, $matches);
foreach ($matches[2] as $class)
{
if(!class_exists($class))
eval('class '.$class.' { }');
}
}
return unserialize($serialized_data);
}
// if using php5 you may want to modify to use __autoload function.