陣列與物件的相互轉化
方法1
$arr = json_encode($obj);
$new_arr = json_decode($arr,true);
$new_arr為陣列
方法2
$obj;
$pack = array();
foreach ($obj as $k => $v) {
$pack[$k] = $v->user_name;
}
$pack為陣列
方法3
$arr = (array)$obj;//陣列轉物件
$obj = (object)$arr;//物件轉陣列