我正在尝试根据特定键获取值。密钥在循环中出现,但密钥的索引会有所不同。对于一种情况,它可以是 48,对于其他情况,它可以是 50。共享下面的数组- [info_buyRequest] => Array ( [uenc] => aHR0cDovL2xvY2FsaG9zdC9TdGlja2VyaXR3ZWIvY3VzdG9tLXN0aWNrZXJzL3RyYW5zZmVyLXN0aWNrZXJzLmh0bWw, [product] => 12 [selected_configurable_option] => [related_product] => [qty] => 1 [custom_quantity] => 500 [custom_price1] => 303 [options] => Array ( [47] => [48] => Black [49] => 8x10 cm [51] => [76] => 500 pcs [50] => Array ( [type] => image/png [title] => project_it_Side_Logo.png [quote_path] => custom_options/quote/S/t/056de63143470f3907e354cd38f2dd3a.png [order_path] => custom_options/order/S/t/056de63143470f3907e354cd38f2dd3a.png [fullpath] => /var/www/html/project/pub/media/custom_options/quote/S/t/056de63143470f3907e354cd38f2dd3a.png [size] => 57385 [width] => 1294 [height] => 353 [secret_key] => 056de63143470f3907e3 ) ) [skipbutton] => 0 )
2 回答
德玛西亚99
TA贡献1770条经验 获得超3个赞
试试下面的代码。它为你工作。
$options = $objectName["info_buyRequest"]["options"];
$quotePaths = [];
foreach($options as $option){
if( is_array ($option) && isset($option['quote_path'])){
$quotePaths[] = $option['quote_path'];
}
}
大话西游666
TA贡献1817条经验 获得超14个赞
遍历options数组,并使用is_array如下方式找到数组:
$array = $yourObjectName["info_buyRequest"]["options"];
$innerArray = array();
foreach($array as $value){
if( is_array ($value)){
$innerArray = $value;
break;
}
}
- 2 回答
- 0 关注
- 83 浏览
添加回答
举报
0/150
提交
取消