对象转化为数组
/**
* 对象转换为数组
* @param 需要转换的数组 $array
* @return array
*/
function object_array($array) {
if(is_object($array)) {
$array = (array)$array;
} if(is_array($array)) {
foreach($array as $key=>$value) {
$array[$key] = $this->object_array($value);
}
}
return $array;
}
function objarray_to_array($obj) {
$ret = array();
foreach ($obj as $key => $value) {
if (gettype($value) == "array" || gettype($value) == "object"){
$ret[$key] = objarray_to_array($value);
}else{
$ret[$key] = $value;
}
}
return $ret;
}