php 5.4 json_encode($str, JSON_UNESCAPED_UNICODE);
5.4版本以下
方法一
function encode_json($str){
$code = json_encode($str);
return preg_replace("#\\\u([0-9a-f]+)#ie", "iconv('UCS-2', 'UTF-8', pack('H4', '\\1'))", $code);
}
方法二
function encode_json($str) {
return urldecode(json_encode(url_encode($str)));
}
/**
*
*/
function url_encode($str) {
if(is_array($str)) {
foreach($str as $key=>$value) {
$str[urlencode($key)] = url_encode($value);
}
} else {
$str = urlencode($str);
}
return $str;
}