We need to improve our programming ideas and apply them flexibly in the continuous experience accumulation.
Later read Json_encode's document only to know that it can only encode UTF-8 characters. The problem is that the returned character is GB2312, how it becomes UTF-8, and it is best to convert the entire array UTF-8. After the search has the following code to resolve the PHP service side return JSON problem:
- function EncodeUTF8 ($array)
- {
- foreach ($array as $key=>$value)
- {
- if (!is_array ($value))
- {
- $array [$key]=mb_convert
_encoding ($value, "UTF-8", "GBK");
- }
- Else
- {
- EncodeUTF8 ($array [$key]);
- }
- }
- return $array;
- }
Each time the result is returned:
- Echo ' {"Total": "'. $rscount. '
"," Results ": '. Json_encode
The above code is a concrete solution to the JSON problem returned by the PHP server.
http://www.bkjia.com/PHPjc/446105.html www.bkjia.com true http://www.bkjia.com/PHPjc/446105.html techarticle we need to improve our programming thinking in the continuous accumulation of experience, flexible use later to see Json_encode documents only know, it can only encode UTF-8 characters. The problem is to return ...