当前位置:Gxlcms > PHP教程 > phpobject转数组示例_php实例

phpobject转数组示例_php实例

时间:2021-07-01 10:21:17 帮助过:24人阅读

代码如下:
function std_class_object_to_array($stdclassobject)
{
$_array = is_object($stdclassobject) ? get_object_vars($stdclassobject) : $stdclassobject;

foreach ($_array as $key => $value) {
$value = (is_array($value) || is_object($value)) ? std_class_object_to_array($value) : $value;
$array[$key] = $value;
}

return $array;
}

人气教程排行