note 105874 modified in function.is-object by danbrown
| From: | danbrown@php.net | Date: | Wed, 21 Sep 2011 19:35:44 +0000 |
| Subject: | note 105874 modified in function.is-object by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-183340@lists.php.net to get a copy of this message | ||
Unserializes data as returned by the standard PHP serialize() function. If the unserialized object
is not an array, it will be converted to one, particularily useful if it returns a
__PHP_Incomplete_Class.
<?php
/**
*
* @param string $data Serialized data
*
* @return array Unserialized array
*/
function unserialize2array($data) {
$obj = unserialize($data);
if(is_array($obj)) return $obj;
$arr = array();
foreach($obj as $k=>$v) {
$arr[$k] = $v;
}
unset($arr['__PHP_Incomplete_Class_Name']);
return $arr;
}
?>
--was--
<?php
/**
* Unserializes data as returned by the standard PHP serialize() function.
* If the unserialized object is not an array, it will be converted to one,
* particularily useful if it returns a __PHP_Incomplete_Class.
*
* @param string $data Serialized data
*
* @return array Unserialized array
*/
function unserialize2array($data) {
$obj = unserialize($data);
if(is_array($obj)) return $obj;
$arr = array();
foreach($obj as $k=>$v) {
$arr[$k] = $v;
}
unset($arr['__PHP_Incomplete_Class_Name']);
return $arr;
}
http://php.net/manual/en/function.is-object.php