如何从这个子数组中提取PHP字符串?
我看到的阵列是:如何从这个子数组中提取PHP字符串?,php,bigcommerce,arrays,Php,Bigcommerce,Arrays,我看到的阵列是: Array ( [0] => Array ( [0] => Bigcommerce\Api\Resources\ProductCustomField Object ( [ignoreOnCreate:protected] => Array ( [0] => id
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;
}
好的,看看,似乎您应该能够使用magic\uuu get
方法。试一试
$array[0][0]->name == 'Artist'
自定义字段的值将存储在该自定义字段的“文本”资源中 请参阅以下链接,从中可以查看自定义字段的4个属性。
是否有办法访问受保护的
$fields
属性,比如通过getter(例如$obj->getFields()
),我不确定。我无法找到清晰的文档,但我认为这应该查找customfields。。。Bigcommerce::getProductCustomFields($product->id);但是我仍然不知道如何从那里访问它。请添加var_export($yourArray),这样我们就可以更容易地使用它并运行测试了吗?array(0=>array(0=>Bigcommerce\Api\Resources\ProductCustomField:::u set_state(array)('ignoreOnCreate'=>array(0=>'id',1=>'product_id',),'ignoreOnUpdate'=>array(0=>'id',1=>'product\u id',),'fields'=>stdClass::\u set\u状态(数组('id'=>17,'product\u id'=>3232,'name'=>'Artist','text'=>'Test',),'id'=>17,'ignoreIfZero'=>array(),),)我没有看过。使用这些函数可能更容易。但对于我为产品(即艺术家名称)创建的自定义值的$field是什么,我仍然感到困惑