原来的代码是这样的:
$str = preg_replace('/[^(\x20-\x7F)]*/', '', $str);
这个正则把非ASCII字符都过滤掉了。因为返回是JSON格式数据,只替换掉“[”和“]”就可以了吧,至少别把中文给替换了。(也许我自己也可以搞定了。直接替换“[”和“]”,直接去掉这个正则)
谢谢各位!
$str = preg_replace('/[^(\x20-\x7F)]*/', '', $str);
这个正则把非ASCII字符都过滤掉了。因为返回是JSON格式数据,只替换掉“[”和“]”就可以了吧,至少别把中文给替换了。(也许我自己也可以搞定了。直接替换“[”和“]”,直接去掉这个正则)
谢谢各位!
6 条回复 • 1970-01-01 08:00:00 +08:00
|
1
xuwenhao 2011 年 5 月 24 日
/\[|\]/ 不可以么?
|
|
2
2014 OP |
|
3
reus 2011 年 5 月 24 日
json_decode() = =
|
|
5
webgeekman 2011 年 8 月 25 日
如果需要被替换的内容类似:[asdf[sdf][]sdfsdf[sdfasdfasfd]
那么xuwenhao 的方法 “/\[|\]/”完全可以啊。 楼主最好将需要替换的内容截取出一段,否则大家没法帮你。 |
|
6
Weakdancer 2011 年 8 月 25 日
$str = json_decode($str,true);
|