The following PHP code resolves the following issues:
1.json_encode UTF8 code after the Chinese string is not readable
The problem of Chinese garbled characters in 2.json_encode multi-series Group
3.json_encode array contains a newline error problem
4.json_encode the key in the array is Chinese
Copy CodeThe code is as follows:
function _encode ($arr)
{
$na = Array ();
foreach ($arr as $k = = $value) {
$na [_urlencode ($k)] = _urlencode ($value);
}
Return Addcslashes (UrlDecode (Json_encode ($na)), "\\r\\n");
}
function _urlencode ($elem)
{
if (Is_array ($elem)) {
foreach ($elem as $k = = $v) {
$na [_urlencode ($k)] = _urlencode ($v);
}
return $na;
}
Return UrlEncode ($elem);
}
http://www.bkjia.com/PHPjc/313650.html www.bkjia.com true http://www.bkjia.com/PHPjc/313650.html techarticle the following PHP code resolves the following problem: 1.json_encode UTF8 code after the Chinese string is not readable 2.json_encode multi-series group Chinese garbled Problem 3.json_encode array contains newline ...