PHP Json_encode Questions

Source: Internet
Author: User
PHP Json_encode will convert the characters inside the array into a string similar to \u821c, is there any way not to turn? or reverse it, but still keep the JSON format.


Reply to discussion (solution)

When you read it with JS, it's kanji.

I know that JS read out is a Chinese character, but I need the answer is not what you say this, but I asked, and I did not say I was using JS read it ...

PHP 5.4 and later, you can add a second parameter Json_unescaped_unicode

or simply

$a = Array (' charset ' = ' Chinese '); array_walk_recursive ($a, function (& $v) {$v = UrlEncode ($v);}); Echo UrlDecode (Json_encode ($a));
{"CharSet": "Chinese"}

Don't even utf-8.

Reference: http://blog.csdn.net/fdipzone/article/details/28766357

PHP 5.4 and later, you can add a second parameter Json_unescaped_unicode

or simply

$a = Array (' charset ' = ' Chinese '); array_walk_recursive ($a, function (& $v) {$v = UrlEncode ($v);}); Echo UrlDecode (Json_encode ($a));
{"CharSet": "Chinese"}

Don't even utf-8.



My php5.4 CHM manual above actually did not write a second parameter, looks like to update the manual ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.