json_encode()函數(shù)轉(zhuǎn)碼時,中文由于要轉(zhuǎn)成Unicode會出現(xiàn)中文不能正常顯示,看到有這樣一個函數(shù)functionjsons_encode($array){//定義一個新的數(shù)據(jù)$newArray=array();//遍歷已有數(shù)組,將每個值urlencode一下foreach($arrayas$key=>$value){$newArray[$key]=>urlencode($value);}//用urldecode將值反解returnurldecode(json_encode($newArray));}我寫得代碼如下這里我打開的是一個utf-8編碼的中文文本,測試時遇到這樣的錯誤:Parseerror:syntaxerror,unexpectedT_DOUBLE_ARROWinD:\wamp\www\test.phponline8應(yīng)該是"=>"這個符號用的有問題,不過不知道如何修改,望大神們指點
自定義json轉(zhuǎn)碼函數(shù)出現(xiàn)錯誤
開滿天機
2019-04-21 20:37:29