PHP对象转数组
2013-6-21 17:15 Friday  

分类: PHP 标签: function class obj return array 评论(30) 浏览(34395)

<?php
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;
}

+1 17

留下你的看法: