首页 > IT职业 > IT图书 > php对象转数组的方法
static function object2Array($object)
{
$result = array();
if (!$object) {return $result;}
$object = is_object($object) ? get_object_vars($object) : $object;
foreach ($object as $key => $val) {
$val = (is_object($val) || is_array($val)) ? self::object2Array($val) : $val;
$result[$key] = $val;
}
return $result;
}
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4741/viewspace-2801858/ ,如需转载,请注明出处,否则将追究法律责任。