I need help. I have an array:
$A =
array(
"0" =>
array(
"1" => array('name' => '1234', 'value' => '1'),
"2" => array('name' => '5678', 'value' => '8')
),
"1" =>
array(
"1" => array('name' => '5678', 'value' => '5')
)
);
How can I get the value
(in foreach loop) from arrays if array key name
value is 5678
?
Hope this will help
foreach ($A as $B) {
foreach ($B as $C) {
if ($C['name'] == '5678') {
echo $C['value'].'<br>';
}
}
}
You can do something like this:
foreach ($A as $array_item) {
foreach ($array_item as $inner_array) {
if ($inner_array['name'] == '5678') {
var_dump($inner_array['value']);
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.