json_endoce: http://cn.php.net/json_encode json_dedoce: http://cn.php.net/json_decode
json_encode — JSON encodes the variable and returns the JSON form of the value, for example:
<?php $arr = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5); echo json_encode($arr); ?>
The output after the above code is executed:
{"a":1,"b":2,"c":3,"d":4,"e":5}
If the data source to be encoded (generally is an array), the value contains Chinese, and the output after json_encode processing is unicode encoding.
<?php $arr = array ('a'=>'脚本之家'); echo json_encode($arr); ?>
The output after the above code is executed:
{"a":"\u811a\u672c\u4e4b\u5bb6"}
The bottom layer of PHP has been processed by unicode. If you think it is not intuitive enough, you can use the urlencode and urldecode methods to bypass the process of transcoding to unicode:
$arr = array ('a'=>urlencode('PHP中文网')); echo urldecode(json_encode($arr));
After the above code is executed, the output is:
{"a":"PHP中文网"}
For more related articles that teach you how to use PHP to output Chinese JSON strings, please pay attention to 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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

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

SublimeText3 Chinese version
Chinese version, very easy to use

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft