父子无限分类
原始数组
<?
/*
获取无线分类,对无线分类进行节点路径排列
*/
$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
(
友情提示:垃圾评论一律封号 加我微信:826096331拉你进VIP群学习群