Home  >  Article  >  Backend Development  >  How to convert php array to json and display Chinese

How to convert php array to json and display Chinese

藏色散人
藏色散人Original
2020-10-29 09:22:433224browse

How to convert php array to json and display Chinese: First create a PHP sample file; then use the "json_encode($var,JSON_UNESCAPED_UNICODE);" method to convert the array to json without garbled Chinese characters. Can.

How to convert php array to json and display Chinese

Recommended: "PHP Video Tutorial"

php converts arrays to json without Garbled characters appear in Chinese

One of the more convenient methods is that as long as your php is 5.4 or above, you can use the following method:

json_encode($var,JSON_UNESCAPED_UNICODE); The sentence JSON_UNESCAPED_UNICODE is the key.

The Chinese that comes out in this way will not be garbled.

The above is the detailed content of How to convert php array to json and display Chinese. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn