php json_decode有关问题

WBOY
Release: 2016-06-13 12:14:50
Original
856 people have browsed it

php json_decode问题
一段代码说明问题:

$str = '{"name":"\xe7"}';<br />$json = json_decode($str, true);<br />var_dump($json);
Copy after login


出来的$json是null

问题是:
我该怎样获得这个$json['name'];呢?  

我觉得这个问题大概很简单,应该就是个编码的问题,但是我不知道该怎样在网上搜索

提前谢过大家了
------解决思路----------------------
$str = '{"name":"\xe7"}';
$str = preg_replace('/\\\x(..)/', '\u00$1', $str);
$json = json_decode($str, true);
var_dump($json);

array(1) {
  ["name"]=>  string(2) “?"
}

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!