DERP.获取'致命错误:无法使用stdClass类型的对象作为数组'
我不知道我在这里做错了什么:
foreach ($json->result->items[$key]->attributes->attribute as $attrib => $val)
{
if($json->result->items[$key]->attributes->attribute[$attrib]->name == 'cannot_trade')
{
$notrade=1;
echo 'Item ' . $key . ' is not tradeable' . $br;
}
}
Run Code Online (Sandbox Code Playgroud)
这是数据:
[attributes] => stdClass Object
(
[attribute] => Array
(
[0] => stdClass Object
(
[name] => custom employee number
[class] => set_employee_number
[value] => 0
)
[1] => stdClass Object
(
[name] => cannot trade
[class] => cannot_trade
[value] => 1
)
)
)
Run Code Online (Sandbox Code Playgroud)
本质上,我正在尝试测试'属性'数组是否具有cannot_trade东西.有时,父对象没有"属性"对象