
/** |
* 对象转换成数组 |
* |
* @param object $obj 对象 |
* @return array 数组 |
*/ |
function ob2ar($obj){ |
if(is_object($obj)){ |
$obj = (array)$obj; |
$obj = ob2ar($obj); |
}else if(is_array($obj)){ // 如果对象里面混有数组内容 |
foreach($obj as $key => $value){ |
$obj[$key] = ob2ar($value); |
} |
} |
return $obj; |
} |
//另外,json_decode() 的第二个参数可以控制返回对象还是数组,为true时返回数组 |



