我在看的数组是这样的:如何从此子数组中提取PHP字符串?
Array
(
[0] => Array
(
[0] => Bigcommerce\Api\Resources\ProductCustomField Object
(
[ignoreOnCreate:protected] => Array
(
[0] => id
[1] => product_id
)
[ignoreOnUpdate:protected] => Array
(
[0] => id
[1] => product_id
)
[fields:protected] => stdClass Object
(
[id] => 17
[product_id] => 3232
[name] => Artist
[text] => Test
)
[id:protected] => 17
[ignoreIfZero:protected] => Array
(
)
)
)
)
我要检查,看看是否“艺术家”在一个PHP条件语句存在。但我不知道如何把'艺术家'变成一个字符串。
更新: 我没有找到懂得如何提取值转换成字符串,但我得到了我一直在寻找使用相关的Bigcommerce API的方法:
$customs = Bigcommerce::getProductCustomFields($product->id);
foreach($customs as $custom) {
if($custom->name == 'Artist'): // do something
endif;
}
有没有一种方法可以通过getter(例如'$ obj-> getFields()')来访问'ProductCustomField'保护的$ fields'属性? – Phil
我不确定。我无法找到明确的文档,但我认为这应该查找自定义字段... Bigcommerce :: getProductCustomFields($ product-> id); 但我仍然不知道如何从中访问它。 – osakagreg
您是否可以添加var_export($ yourArray),以便我们更容易地使用它并运行测试? – MJoraid