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

PHP unlimited classification father and son tracing method

WBOY
Release: 2016-07-25 09:09:28
Original
953 people have browsed it
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
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template