The use of PHP recursive get all of the superior section

    / ** 
     * Get all of the higher sections 
     * @param $ category_id 
     * @param Array Array $ 
     * @return Array 
     * @author Ningjia Bing <[email protected]> 
     * / 
    public static function getTreeCate ($ category_id, $ = array []) { 

        $ is_parent = D ( 'Article This article was / the Category') -> WHERE ([ "ID" => $ category_id]) -> Find (); 
     // data present in the array $ array [] = $ is_parent;
     // if higher id, continue recursive query section IF ($ is_parent [ "the parent_id"]) { return Self :: getTreeCate ($ is_parent [ 'the parent_id'], $ Array); } return $ Array; }

  

Which it is important to note that define the location of the array, with the recursive function return.

Guess you like

Origin www.cnblogs.com/ningjiabing/p/11224419.html