中文 一起 引号 style 字符 之前 tro 去掉 还要
part 1
一般使用时,json_encode会和json_decode一起使用,decode之后和encode之前会一模一样,不用担心;
如果确实需要在decode之前去掉这对引号也很简单,使用trim()函数 trim(json_encode($str),‘"‘);
part 2
如果你的字符串含中文,发现encode失败了,为bool(false)时,你看看你的文件编码是不是UTF-8哦,GBK的话就会为false哦;
如果你确实需要gbk编码且还要encode的话,有一种解决方案是:先使用urlencode一下再去encode;
PHP json_encode函数使用后多出来首尾的引号、中文转码问题
中文 一起 引号 style 字符 之前 tro 去掉 还要
原文:http://www.cnblogs.com/wxgthinking/p/7903395.html
来源: http://www.bubuko.com/infodetail-2408760.html