无法将类型为stdClass的对象用作数组? [英] Cannot use object of type stdClass as array?
本文介绍了无法将类型为stdClass的对象用作数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用json_decode()
时出现一个奇怪的错误.它可以正确解码数据(我使用print_r
看到了),但是当我尝试访问数组中的信息时,我得到了:
I get a strange error using json_decode()
. It decode correctly the data (I saw it using print_r
), but when I try to access to info inside the array I get:
Fatal error: Cannot use object of type stdClass as array in
C:\Users\Dail\software\abs.php on line 108
我只想做:$result['context']
其中$result
具有json_decode()
返回的数据
I only tried to do: $result['context']
where $result
has the data returned by json_decode()
如何读取此数组中的值?
How can I read values inside this array?
推荐答案
使用 json_decode
使其返回数组:
Use the second parameter of json_decode
to make it return an array:
$result = json_decode($data, true);
这篇关于无法将类型为stdClass的对象用作数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文