以递归方式在数组中搜索键
private function find($needle, $haystack) {
foreach ($haystack as $name => $file) {
if ($needle == $name) {
return $file;
} else if(is_array($file)) { //is folder
return $this->find($needle, $file); //file is the new haystack
}
}
return "did not find";
}
嘿,此方法在关联数组中搜索特定键并返回与其关联的值。递归存在一些问题。有什么线索吗?