2 回答

TA貢獻1830條經(jīng)驗 獲得超3個贊
您可以像下面這樣循環(huán)數(shù)組:
foreach ($array['items'][0]['custom_attributes'] as $key => $item) {
if($item['attribute_code'] == 'ages') echo $item['value']
}

TA貢獻1798條經(jīng)驗 獲得超7個贊
您可以使用 array_walk_recursive
$searchCode = 'ages';
$attributeValue = '';
$flag = false;
array_walk_recursive($a, function($item, $key, &$flag) use ($searchCode,&$attributeValue){
($key == 'attribute_code' && $item == $searchCode) ? ($flag = true) : '';
!empty($flag) ? ($attributeValue = $item) : '';
}, $flag);
echo $attributeValue;
工作示例:https : //3v4l.org/erlZD
- 2 回答
- 0 關(guān)注
- 126 瀏覽
添加回答
舉報