ThinkPHP无限级分类

<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2009 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
namespace Org\Util;
class Trees {
   static public $treeList = array();//存放无限级分类的结果
    public function Create($data,$pid = 0){
      foreach($data as $key => $value){
          if($value['pid'] == $pid){
            self::$treeList[] = $value;
            unset($data[$key]);
            self::Create($data,$value['id']);
          }

      }
       return self::$treeList;
    }

}

 

posted @ 2016-02-18 09:24  侠岚之弋痕夕  阅读(454)  评论(0)    收藏  举报
Where is the starting point, we don't have a choice, but the destination where we can pursue!