php infinite classification parent classification and sub-category tracing method, the code snippet is as follows:
Copy to ClipboardQuoted content:
[www.bkjia.com]
//Return all leaf nodes
public function scanNodeOfTree($result,$fid){
$checkexist = false;
for ($i=0; $i
if($fid == $result[$i]['ParentId']){
$checkexist = true;
$arr .= $this->scanNodeOfTree($result,$ result[$i]['ID']).',';
}
}
if(!$checkexist){
return $fid;
}
return $ arr;
}
//Return all superior nodes
public function getNodeOfTree($result,$id,$arr){
if($id == 0){
return $arr;
}
foreach ($result as $items){
if($id == $items['ID']){
$arr[] = array($ items['CateName'],$items['ID']);
$return = $this->getNodeOfTree($result,$items['ParentId'],$arr);
}
}
return $return;
}
http://www.bkjia.com/PHPjc/363936.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/363936.htmlTechArticlephp Traceability method of parent category and subcategory of unlimited categories, the code snippet is as follows: Copy to Clipboard Quoted content: [www.veryhuo.com] //Return all leaf nodes public funct...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn