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

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

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


父子无限分类

原始数组

/*
获取无线分类,对无线分类进行节点路径排列
*/
$a=array (
0 =>
array (
'id' => '134',
'fid' => '0',
'name' => 't',
),
1 =>
array (
'id' => '133',
'fid' => '0',
'name' => 'k',
),
2 =>
array (
'id' => '132',
'fid' => '0',
'name' => 'j',
),
3 =>
array (
'id' => '137',
'fid' => '133',
'name' => '我是k的分类1',
),
4 =>
array (
'id' => '136',
'fid' => '134',
'name' => '我是t的分类t2',
),
5 =>
array (
'id' => '135',
'fid' => '134',
'name' => '我是t的分类t1',
),
6 =>
array (
'id' => '138',
'fid' => '137',
'name' => '我是k的分类1-1',
),
7 =>
array (
'id' => '139',
'fid' => '138',
'name' => '我是k的分类1-1-1',
),
8 =>
array (
'id' => '140',
'fid' => '139',
'name' => '我是k的分类1-1-1-1',
),
)
?>

开始形成树,并且增加路径,树形数组为$trees
Array
(
[0] => Array
(
[id] => 134
[fid] => 0
[name] => t
[path] => 134
[_sub] => Array
(
[0] => Array
(
[id] => 136
[fid] => 134
[name] => 我是t的分类t2
[path] => 134,136
)

[1] => Array
(
[id] => 135
[fid] => 134
[name] => 我是t的分类t1
[path] => 134,135
)

)

)

[1] => Array
(
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!