日期:2014-05-17  浏览次数:20629 次

PHP数组与对象的互相转换
array to object, object to array
// Funcion de Object a Array   
function object_to_array($object)
    {
        if(is_array($object) || is_object($object)){
            $array = array();
            foreach($object as $key => $value){
                $array[$key] = $this->object_to_array($value);
            }
            return $array;
        }
        return $object;
    }

// Funcion de Array a Object
function array_to_object($array = array())
    {
        return (object) $array;
    }