gpt4 book ai didi

Php 不能使用对象 stdClass 作为数组

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:03:59 24 4
gpt4 key购买 nike

<分区>

德普。出现“ fatal error :无法将 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;
}
}

这是数据:

[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
)
)
)

本质上,我正在尝试测试“属性”数组是否有 cannot_trade 问题。有时,父对象没有“属性”对象

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com