新聞中心
本文小編為大家詳細介紹“php如何把json unicode轉(zhuǎn)中文”,內(nèi)容詳細,步驟清晰,細節(jié)處理妥當,希望這篇“php如何把json unicode轉(zhuǎn)中文”文章能幫助大家解決疑惑,下面跟著小編的思路慢慢深入,一起來學習新知識吧。
我們提供的服務(wù)有:成都網(wǎng)站建設(shè)、網(wǎng)站制作、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認證、鄂溫克ssl等。為成百上千企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學管理、有技術(shù)的鄂溫克網(wǎng)站制作公司
php把json unicode轉(zhuǎn)中文的方法:1、使用“json_encode($log['result_data'],JSON_UNESCAPED_UNICODE);”方法進行轉(zhuǎn)換;2、使用“function unicodeDecode($unicode_str){...}”方法進行轉(zhuǎn)換即可。
PHP把unicode編碼的json字符串轉(zhuǎn)中文
json中中文被編碼
$s = '[{"param_name":"email","param_caption":"\u90ae\u7bb1","operator":"\u5305\u542b","value":"aaaa\u5927\u592b\u6492"}]';
將中文編碼轉(zhuǎn)成中文
方法1.
json_encode($log['result_data'],JSON_UNESCAPED_UNICODE);
方法2.
/**
* 把unicode編碼的字符串轉(zhuǎn)為人眼可看的字符串
* @param $unicode_str
*
* @return string
*/
function unicodeDecode($unicode_str){
$unicode_str = str_replace('"', '\"', $unicode_str);
$unicode_str = str_replace("'", "\'", $unicode_str);
$json = '{"str":"'.$unicode_str.'"}';
$arr = json_decode($json,true);
if(empty($arr)){
return '';
}
return $arr['str'];
}
結(jié)果:
[{"param_name":"email","param_caption":"郵箱","operator":"包含","value":"aaaa大夫撒"}]
讀到這里,這篇“php如何把json unicode轉(zhuǎn)中文”文章已經(jīng)介紹完畢,想要掌握這篇文章的知識點還需要大家自己動手實踐使用過才能領(lǐng)會,如果想了解更多相關(guān)內(nèi)容的文章,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
文章標題:php如何把jsonunicode轉(zhuǎn)中文
本文路徑:http://fisionsoft.com.cn/article/gephgd.html