我有多个阵列:
$meta_boxes[] = array(
'id' => 'measurements',
'title' => 'Measurements',
'fields' => array(
array(
'name' => 'Length',
'id' => 'length',
'type' => 'text',
'std' => ''
),
array(
'name' => 'Manufacturer Length',
'id' => 'manufacturer_length',
'type' => 'text',
'std' => ''
)
)
);
$meta_boxes[] = array(
'id' => 'colors',
'title' => 'Colors',
'fields' => array(
array(
'name' => 'exterior',
'id' => 'exterior',
'type' => 'text',
'std' => ''
etc...
我如何从name
数组fields
数组$meta_boxes[]
数组得到id = measurements
元素的值?
答案 0 :(得分:2)
尝试这样的事情:
foreach ($meta_boxes as $meta_box) {
if($meta_box['id'] !== 'measurements') {
continue;
}
$output = $meta_box['fields'];
break;
}