Home >Backend Development >PHP Tutorial >PHP infinite classification father and son tracing method_PHP tutorial

PHP infinite classification father and son tracing method_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-21 14:57:53851browse

php infinite classification parent classification and sub-category tracing method, the code snippet is as follows:

Copy to ClipboardLiehuo.Net CodesQuoted content: [www.bkjia.com] //Return all leaf nodes
public function scanNodeOfTree($result,$fid){
$checkexist = false;
for ($i=0; $iif($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;
}

www.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