php把json unicode转中文的方法:1、使用“json_encode($log['result_data'],json_unescaped_unicode);”方法进行转换;2、使用“function unicodedecode($unicode_str){...}”方法进行转换即可。

本教程操作环境:Windows10系统、PHP8.1版、DELL G3电脑
php怎么把json unicode转中文?
PHP把unicode编码的json字符串转中文
json中中文被编码
$s = '[{"param_name":"email","param_caption":"u90aeu7bb1","operator":"u5305u542b","value":"aaaau5927u592bu6492"}]';将中文编码转成中文
方法1.
json_encode($log['result_data'],JSON_UNESCAPED_UNICODE);
方法2.
/**
* 把unicode编码的字符串转为人眼可看的字符串
* @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'];
}结果:
[{"param_name":"email","param_caption":"邮箱","operator":"包含","value":"aaaa大夫撒"}]推荐学习:《》
以上就是php怎么把json unicode转中文的详细内容,更多请关注本站点其它相关文章!
本文地址:https://www.stayed.cn/item/26908
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我