如何检查数组的子键中是否存在键?如果找到该项目的该键,则返回该项目?
例如,我有这个数组,
Array
(
[0] => Array
(
[a] => Array
(
[quantity_request] => 1
[time_created] => 1339688613
[variant] => Array
(
)
)
)
[1] => Array
(
[b] => Array
(
[quantity_request] => 1
[time_created] => 1339688631
[variant] => Array
(
)
)
)
[2] => Array
(
[c] => Array
(
[quantity_request] => 1
[time_created] => 1339688959
[variant] => Array
(
)
)
)
)
我想找到键'b'并返回它下面的所有内容,就像这就是我所追求的,
[b] => Array
(
[quantity_request] => 1
[time_created] => 1339688631
[variant] => Array
(
)
)
我尝试了这个,但没有任何回报,
if (array_key_exists('b', $this->content)) {
echo "The 'b' element is in the array";
}
有任何想法吗?