PHP JSON乱码简洁的解决办法
$arr = array('ret'=>400,
'msg'=>'服务器地址不允许',
'data'=>'');
foreach ( $arr as $key => $value ) {
$arr[$key] = urlencode ( $value );
}
header("content-type:application/json;charset=utf-8");
echo urldecode ( json_encode ( $arr ) );
exit;
这样一定是中文的:
{“ret”:”400”,”msg”:”服务器地址不允许”,”data”:”“}