我创建递归函数以在$allCategories
数组上行走,但它给出了错误500.错误日志/var/log/httpd/domains/mydomain.com.error.log
并显示除通知之外没有显示任何内容的所有错误。我做错了什么?
$categoryArray = $this->searchNodes($allCategories,$category->id);
public function searchNodes($tree,$search_id){
foreach($tree as $array){
if($array['id_category'] == $search_id){
return $array;
} else{
if(array_key_exists('children', $array))
$childrenNodes = $this->searchNodes($array['children'],$search_id);
if($childrenNodes != false){
return $childrenNodes;
}
}
}
return false;
}