PHP实现无级递归分门别类(ThinkPHP框架)
Jun 13, 2016 pm 12:23 PM
class
tree
PHP实现无级递归分类(ThinkPHP框架)
<span style="color: #008000;">/*</span><span style="color: #008000;">** 无级递归分类* @param int $assortPid 要查询分类的父级id* @param mixed $tag 上下级分类之间的分隔符* @return string $tree 返回的分类树型结构结果 *</span><span style="color: #008000;">*/</span><span style="color: #0000ff;">function</span> recursiveAssort(<span style="color: #800080;">$assortPid</span>, <span style="color: #800080;">$tag</span> = ''<span style="color: #000000;">){ </span><span style="color: #800080;">$assort</span> = M('goods_class')->where("class_pid = <span style="color: #800080;">$assortPid</span>")->field('class_id, class_name')-><span style="color: #000000;">select(); </span><span style="color: #0000ff;">foreach</span> (<span style="color: #800080;">$assort</span> <span style="color: #0000ff;">as</span> <span style="color: #800080;">$value</span><span style="color: #000000;">) { </span><span style="color: #800080;">$tree</span> .= '<option value="' . <span style=" color:>$value['class_id'] . '">' . <span style="color: #800080;">$tag</span> . <span style="color: #800080;">$value</span>['class_name'] . '</option>'<span style="color: #000000;">; </span><span style="color: #800080;">$tree</span> .= recursiveAssort(<span style="color: #800080;">$value</span>['class_id'], <span style="color: #800080;">$tag</span> . ' '<span style="color: #000000;">); } </span><span style="color: #0000ff;">return</span> <span style="color: #800080;">$tree</span><span style="color: #000000;">;}</span>
Copy after login
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

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to use classes and methods in Python

Replace the class name of an element using jQuery

How SpringBoot encrypts and protects class files through custom classloader

Use tree to generate a file directory tree for display

Methods of predefined Class objects in java

Detailed explanation of PHP Class usage: Make your code clearer and easier to read

Vue error: Unable to use v-bind to bind class and style correctly, how to solve it?
