网上找了几个例子,最后这个例子比较理想,一次过,好使
//数组转对象
private function array_to_object($arr) {
if (gettype($arr) != 'array') {
return;
}
foreach ($arr as $k => $v) {
if (gettype($v) == 'array' || getType($v) == 'object') {
$arr[$k] = (object)array_to_object($v);
}
}
return (object)$arr;
}