<?php
$a = Array
(
'items' => Array
(
'0' => Array
(
'sku' => 'SCB20',
'custom_attributes' => Array
(
'0' => Array
(
'attribute_code' => 'ages',
'value' => 17
),
'1' => Array
(
'attribute_code' => 'description',
'value' => 'description data'
),
'2' => Array
(
'attribute_code' => 'image',
'value' => 'cl2eojpu9.jpg'
)
)
)
)
);
$searchCode = 'ages';
$attributeValue = '';
$flag = false;
array_walk_recursive($a, function($item, $key, &$flag) use ($searchCode,&$attributeValue){
if($key == 'attribute_code' && $item == $searchCode){
$flag = true;
}
if($flag){
$attributeValue = $item;
}
}, $flag);
echo $attributeValue;
preferences:
58.52 ms | 402 KiB | 5 Q