/** * 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