php数组转json中文乱码解决办法

为数组里的每个元素进行urlencode() 转码 后再用json_encode() 转为json即可, 解码使用json_decode()

示例:

foreach ( $result as $keys => $value )
//包含中文的二维数组$result转json,数组内部元素一一使用urlencode转换即可保证中文不乱码 { foreach($value as $key=>$column){ $testJSON[$keys][$key] = urlencode ( $column ); } } var_dump( json_encode ( $testJSON ));//转为json $result = urldecode ( json_encode ( $testJSON ) );//转回数组