Home >Backend Development >PHP Tutorial >PHP unlimited classification father and son tracing method

PHP unlimited classification father and son tracing method

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-25 09:09:28978browse
php infinite classification father and son traceability method                  
                                                                                                                                                                                                                                                                                                       



//Return all leaf nodes
public function scanNodeOfTree($result,&$array=array(),$parentId=0,$lv=0){
                                                                                                    using   using   using   using   using           using using           through   through out through out through out through off ‐ through off ‐ ‐‐‐‐
    )$result){
  1.                                                                                                                                      ['lv']=$lv;
  2.                                                                                                                        =$value;
  3.                                                                                          ;scanNodeOfTree($result,$array,$value['ID'],$lv--);
  4.                                                                                           /Return all superior nodes
  5. public function getNodeOfTree($result,$id,$arr){
  6.                                                                                                                             
  7.       foreach ($result as $items){                                                                                                ($id == $items['ID']){                                                          $return = $this->getNodeOfTree( $result,$items['ParentId'],$arr);                                                                     Copy code
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