这样就有值:$a = '{ "a":"www", "b":2}';
$arr = json_decode($a, true);
这样就返回NULL:$a = '{ "a":"你好", "b":2}';
$arr = json_decode($a, true);
为什么出现这种情况呢?该怎么解析带中文的JSON字符串呢?
$arr = json_decode($a, true);
这样就返回NULL:$a = '{ "a":"你好", "b":2}';
$arr = json_decode($a, true);
为什么出现这种情况呢?该怎么解析带中文的JSON字符串呢?
$p_json = json_encode($p);
echo $p_json."<br>";
#{"name":"\u6210\u9f99","0":{"age":55,"cur":"\u7535\u5f71"}}
#\u6210\u9f99 => 成龙,
#\u7535\u5f71 => 电影
print_r(json_decode($p_json));
#stdClass Object ( [name] => 成龙 [0] => stdClass Object ( [age] => 55 [cur] => 电影 ) )
那它也应该能出来东西啊,不能是NULL吧
header("Content-Type: text/html; charset=utf-8");
$p = array("name"=>"成龙",array("age"=>55,"cur"=>"电影"));
$p_json = json_encode($p);