

解决方法一:
<?php
function Notice(){
include './include/conn.php'; //数据库链接文件
$sql_notice =
mysql_query
('SELECT * FROM gg_notice where enable = "1" limit 0,10');
$notice =
mysql_fetch_array
($sql_notice, MYSQL_ASSOC);
$str = json_encode($notice);
//linux
return preg_replace("#\\\u([0-9a-f]{4})#ie", "iconv('UCS-2BE', 'UTF-8', pack('H4', '\\1'))", $str);
//windows
//return preg_replace("#\\\u([0-9a-f]{4})#ie", "iconv('UCS-2LE', 'UTF-8', pack('H4', '\\1'))", $str);
}
?>另外从网上搜索到的其他方法
<?php
/*** json 生成,分析 支持中文
*/
class Json_Helper {
/**
* 生成json
*/
public static function encode($str){
$json = json_encode($str);
//linux
return preg_replace("#\\\u([0-9a-f]{4})#ie", "iconv('UCS-2BE', 'UTF-8', pack('H4', '\\1'))", $json);
//windows
//return preg_replace("#\\\u([0-9a-f]{4})#ie", "iconv('UCS-2LE', 'UTF-8', pack('H4', '\\1'))", $json);
}
/**
* 分析json
*/
public static function decode($str) {
return json_decode($str);
}
}
?>相信看了本文案例你已经掌握了方法,更多精彩请关注Gxl网其它相关文章!
推荐阅读:
jQuery做出垂直半透明手风琴效果
jquery实现导航菜单鼠标提示功能
