我编写了以下函数来按键搜索多维数组,但是如果我使用 key 调用该函数uri
,它会将具有键的数组附加0
到找到的数组中。怎么了?
function search_arr($array, $key, &$found) {
foreach ($array as $k => $each) {
if ($k == $key) {
// output of "print $k = $key" is "0 = uri"
$found[] = $each;
}
if (is_array($each)) {
search_arr($each, $key, $found);
}
}
}