我要在此数组中搜索 50075285 。
$xyz=Array
(
[typeA] => Array
(
[details_typeA] => Array
(
[id] => 50075285
[action_code] => PDF_ONLINE
)
)
[typeB] => Array
(
[details_typeB] => Array
(
[id] => 50075287
[action_code] => offline
)
)
)
答案 0 :(得分:0)
//this gives the exact value in a specific array
//in this case this is the value you want.
$value = $xyz['typeA']['details_typeA']['id'];
OR
//this gives every id in the `details_typeX` array
foreach($xyz as $type){
foreach($type as $details){
$value = $details['id']
}
}
答案 1 :(得分:0)
尝试此功能:
该值应与$ key数组键相关联
您要在数组中搜索的$ value值
function arr_search($array, $key, $value)
{
$results = array();
if (is_object($array)){ $array = (array)$array; }
if (is_array($array))
{
if (isset($array[$key]) && $array[$key] == $value)
$results[] = $array;
foreach ($array as $subarray)
$results = array_merge($results, arr_search($subarray, $key, $value));
}
return $results;
}