查看代码打印
//数组转对象
function arrayToObject($e){
if( gettype($e)!=\'array\' ) return;
foreach($e as $k=>$v){
if( gettype($v)==\'array\' || getType($v)==\'object\' )
$e[$k]=(object)arrayToObject($v);
}
return (object)$e;
}
//对象转数组
function objectToArray($e){
$e=(array)$e;
foreach($e as $k=>$v){
if( gettype($v)==\'resource\' ) return;
if( gettype($v)==\'object\' || gettype($v)==\'array\' )
$e[$k]=(array)objectToArray($v);
}
return $e;
}
来源:https://blog.csdn.net/todayags/article/details/123231464
本站部分图文来源于网络,如有侵权请联系删除。