Home  >  Article  >  Backend Development  >  php json_decode有关问题

php json_decode有关问题

WBOY
WBOYOriginal
2016-06-13 12:14:50879browse

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

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


出来的$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) “?"
}

Statement:
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