当前位置: 编程技术>php
php object转数组示例
来源: 互联网 发布时间:2014-08-26
本文导语: 代码如下: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_arr...
代码如下:
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;
}