Solve Chinese garbled characters in json_encode

Source: Internet
Author: User

 

 

Solve the following problems:
  1. Json_encode Chinese character strings cannot be read
  2. Chinese garbled characters in json_encode multi-level Arrays
  3. An error occurred while changing the line in the json_encode array.
  4. Question about Chinese characters in the json_encode Array
  5. Http://blog.1dnet.net /? Posting = 840
[PHP] Code 01 //http://blog.1dnet.net 02 function  _encode( $arr ) 03 { 04    $na  array (); 05    foreach  $arr  as  $k  =>  $value  ) {   06      $na [_urlencode( $k )] = _urlencode ( $value );   07    } 08    return  addcslashes (urldecode(json_encode( $na )), "\r\n" ); 09 } 10  11 function  _urlencode( $elem ) 12 { 13    if ( is_array ( $elem )){ 14      foreach ( $elem  as  $k => $v ){ 15        $na [_urlencode( $k )] = _urlencode( $v ); 16      } 17      return  $na ; 18    } 19    return  urlencode( $elem ); 20 }

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.