All files and subfolders recursively get PHP tree menu and traverse folder folder

All files and subfolders recursively get PHP tree menu and traverse folder folder

 

 

First, the use of recursive get a tree menu

Data Sheet category (id, name, parent_id)

<? PHP 

class   category { 

  //. 1, all inquiries classified 
    public  function getTree () { 

             $ RES   = SELECT * from categore; 

             $ Tree = $ the this -> Tree ( $ RES ); 

              return  $ Tree ; 
    
    } 

  // 2, through all Categories 
    punlic function Tree ( $ Data , $ PID = 0, $ Lev =. 1 ) { 
    
        $ Tree    = []; 
     the foreach ( $ Data AS $ K => $ V ) { $ Array = $ V; if($v['parent_id']==$pid){ $v['name'] = $v['parent_id']==0 ? $v['name'] :str_repeat('|___',$lev).$v['name']; $tree = $v; } } return $tree; } }

 

Second, the Traverse Folder get all the files and folders in the folder

 

 

Guess you like

Origin www.cnblogs.com/ccw869476711/p/9187618.html