我需要帮助。我有一个数组:
$A =
array(
"0" =>
array(
"1" => array('name' => '1234', 'value' => '1'),
"2" => array('name' => '5678', 'value' => '8')
),
"1" =>
array(
"1" => array('name' => '5678', 'value' => '5')
)
);
如果数组键value
值为name
,如何从数组中获取5678
(在foreach循环中)?
答案 0 :(得分:3)
希望这会有所帮助
foreach ($A as $B) {
foreach ($B as $C) {
if ($C['name'] == '5678') {
echo $C['value'].'<br>';
}
}
}
答案 1 :(得分:0)
您可以这样做:
foreach ($A as $array_item) {
foreach ($array_item as $inner_array) {
if ($inner_array['name'] == '5678') {
var_dump($inner_array['value']);
}
}
}