Home > Backend Development > PHP Tutorial > 看了版主的无限分类,分成树形结构后,怎么还原

看了版主的无限分类,分成树形结构后,怎么还原

WBOY
Release: 2016-06-13 12:06:05
Original
1174 people have browsed it

看了版主的无限分类,分成树形结构后,如何还原

<br>父子无限分类<br><br>原始数组<br><br>/*<br>获取无线分类,对无线分类进行节点路径排列<br>*/<br>$a=array (<br>  0 =><br>  array (<br>    'id' => '134',<br>    'fid' => '0',<br>    'name' => 't',<br>  ),<br>  1 =><br>  array (<br>    'id' => '133',<br>    'fid' => '0',<br>    'name' => 'k',<br>  ),<br>  2 =><br>  array (<br>    'id' => '132',<br>    'fid' => '0',<br>    'name' => 'j',<br>  ),<br>  3 =><br>  array (<br>    'id' => '137',<br>    'fid' => '133',<br>    'name' => '我是k的分类1',<br>  ),<br>  4 =><br>  array (<br>    'id' => '136',<br>    'fid' => '134',<br>    'name' => '我是t的分类t2',<br>  ),<br>  5 =><br>  array (<br>    'id' => '135',<br>    'fid' => '134',<br>    'name' => '我是t的分类t1',<br>  ),<br>  6 =><br>  array (<br>    'id' => '138',<br>    'fid' => '137',<br>    'name' => '我是k的分类1-1',<br>  ),<br>  7 =><br>  array (<br>    'id' => '139',<br>    'fid' => '138',<br>    'name' => '我是k的分类1-1-1',<br>  ),<br>  8 =><br>  array (<br>    'id' => '140',<br>    'fid' => '139',<br>    'name' => '我是k的分类1-1-1-1',<br>  ),<br>)<br>?><br><br>开始形成树,并且增加路径,树形数组为$trees<br>Array<br>(<br>    [0] => Array<br>        (<br>            [id] => 134<br>            [fid] => 0<br>            [name] => t<br>            [path] => 134<br>            [_sub] => Array<br>                (<br>                    [0] => Array<br>                        (<br>                            [id] => 136<br>                            [fid] => 134<br>                            [name] => 我是t的分类t2<br>                            [path] => 134,136<br>                        )<br><br>                    [1] => Array<br>                        (<br>                            [id] => 135<br>                            [fid] => 134<br>                            [name] => 我是t的分类t1<br>                            [path] => 134,135<br>                        )<br><br>                )<br><br>        )<br><br>    [1] => Array<br>        (<div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template