【发布时间】:2011-04-27 21:31:31
【问题描述】:
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";
}
嘿,此方法在关联数组中搜索特定键并返回与其关联的值。递归有问题。有什么线索吗?
【问题讨论】:
-
你怎么不知道它在什么级别?
标签: php arrays search recursion