PHP Handling json_encode Chinese display problem

Source: Internet
Author: User
Tags urlencode

/** * UrlEncode processing of arrays and scalars * usually calls Wphp_json_encode ()  * Handles Json_encode Chinese display problem * @param array $data * @return String */ function Wphp_urlencode ($data) {if (Is_array ($data) | | is_object ($data)) {foreach ($data as $k + = $v) {if (Is_scalar ($v ) {if (Is_array ($data)) {$data [$k] = UrlEncode ($v),} else if (Is_object ($data)) {$data, $k = UrlEncode ($v);}} else if (Is_array ($data)) {$data [$k] = Wphp_urlencode ($v);//Call this function recursively} else if (Is_object ($data)) {$data, $k = Wphp_urlencode ($v);}} return $data;}
/** * JSON encoding *  * solve the Chinese after json_encode () processing after the display is not intuitive * If the default will be "Chinese" into "\u4e2d\u6587", not intuitive * If no special needs, not recommended to use the function, directly using Json_encode Better, Save resources * Json_encode () the parameter encoding format for UTF-8 will work correctly *  * @param array|object $data * @return array|object */function Ch_json _encode ($data) {$ret = Wphp_urlencode ($data); $ret = Json_encode ($ret); return UrlDecode ($ret);}

  

  

PHP Handling json_encode Chinese display problem

PHP Handling json_encode Chinese display problem

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.