PHP json_decode返回空数组 [英] PHP json_decode return empty array
本文介绍了PHP json_decode返回空数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是从php doc( http:// au2 .php.net / manual / en / function.json-decode.php )
I just test this sample from php doc (http://au2.php.net/manual/en/function.json-decode.php)
这是我的代码:
<?php $json = '{"a":1,"b":2,"c":3,"d":4,"e":5}'; echo json_decode($json, true), '<br />';?>
但是它只返回一个EMPTY数组。
But it just returns an EMPTY array.
不知道为什么...曾经四处搜寻,但找不到解决方案。
Have no idea why...Been searching around but no solution found.
请帮助!
推荐答案
您不应使用echo,因为它是一个数组。使用print_r或var_dump即可。
you should not use echo because it is an array. use print_r or var_dump .it works fine
$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
print_r(json_decode($json, true));
输出:
Array
(
[a] => 1
[b] => 2
[c] => 3
[d] => 4
[e] => 5
)
这篇关于PHP json_decode返回空数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文