首页  >  文章  >  后端开发  >  PHP实现无级递归分类(ThinkPHP框架),无级thinkphp_PHP教程

PHP实现无级递归分类(ThinkPHP框架),无级thinkphp_PHP教程

WBOY
WBOY原创
2016-07-13 09:45:39983浏览

PHP实现无级递归分类(ThinkPHP框架),无级thinkphp

<span>/*</span><span>*
*   无级递归分类
*   @param   int     $assortPid   要查询分类的父级id
*   @param   mixed   $tag         上下级分类之间的分隔符
*   @return  string  $tree        返回的分类树型结构结果 
*
</span><span>*/</span>
<span>function</span> recursiveAssort(<span>$assortPid</span>, <span>$tag</span> = ''<span>)
{   
    </span><span>$assort</span> = M('goods_class')->where("class_pid = <span>$assortPid</span>")->field('class_id, class_name')-><span>select();
    </span><span>foreach</span> (<span>$assort</span> <span>as</span> <span>$value</span><span>) {
        </span><span>$tree</span> .= '<option value="' . <span>$value</span>['class_id'] . '">' . <span>$tag</span> . <span>$value</span>['class_name'] . '</option>'<span>;
        </span><span>$tree</span> .= recursiveAssort(<span>$value</span>['class_id'], <span>$tag</span> . '&emsp;'<span>);
    }
    </span><span>return</span> <span>$tree</span><span>;
}</span>

 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1040158.htmlTechArticlePHP实现无级递归分类(ThinkPHP框架),无级thinkphp /* ** 无级递归分类* @param int $assortPid 要查询分类的父级id* @param mixed $tag 上下级分类之间的...
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn