php method to convert json unicode to Chinese: 1. Use the "json_encode($log['result_data'],JSON_UNESCAPED_UNICODE);" method to convert; 2. Use "function unicodeDecode($unicode_str){.. .}" method to convert.
The operating environment of this tutorial: Windows 10 system, PHP version 8.1, DELL G3 computer
How to convert json unicode to Chinese in php ?
PHP converts unicode encoded json string to Chinese
Chinese in json is encoded
$s = '[{"param_name":"email","param_caption":"\u90ae\u7bb1","operator":"\u5305\u542b","value":"aaaa\u5927\u592b\u6492"}]';
Convert Chinese encoding to Chinese
Method 1.
json_encode($log['result_data'],JSON_UNESCAPED_UNICODE);
Method 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']; }
Result:
[{"param_name":"email","param_caption":"邮箱","operator":"包含","value":"aaaa大夫撒"}]
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to convert json unicode to Chinese in php. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 English version
Recommended: Win version, supports code prompts!

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver Mac version
Visual web development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
