为数组里的每个元素进行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 ) );//转回数组

 

相关文章:

  • 2021-12-01
  • 2022-12-23
  • 2022-12-23
  • 1970-01-01
  • 2022-02-20
  • 2022-12-23
  • 2021-12-15
  • 2021-06-30
猜你喜欢
  • 2021-06-13
  • 2022-12-23
  • 2021-06-26
  • 2021-10-19
  • 2022-02-08
  • 2021-10-10
相关资源
相似解决方案