/** * 對數據進行編碼轉換 * @param array/string $data 數組 * @param string $output 轉換後的編碼 */ function array_iconv($data,$output = 'utf-8') { $encode_arr = array('UTF-8','ASCII','GBK','GB2312','BIG5','JIS','eucjp-win','sjis-win','EUC-JP'); $encoded = mb_detect_encoding($data, $encode_arr);//自動判斷編碼 if (!is_array($data)) { return mb_convert_encoding($data, $output, $encoded); } else { foreach ($data as $key=>$val) { if(is_array($val)) { $data[$key] = array_iconv($val, $input, $output); } else { $data[$key] = mb_convert_encoding($data, $output, $encoded); } } return $data; } }