《PHP实战:php两种无限分类方法实例》要点:
本文介绍了PHP实战:php两种无限分类方法实例,希望对您有用。如果有疑问,可以联系我们。
PHP编程一、递归办法
PHP编程$items = array(
1 => array('id' => 1, 'pid' => 0, 'name' => '一级11'),
2 => array('id' => 2, 'pid' => 1, 'name' => '二级21'),
3 => array('id' => 3, 'pid' => 1, 'name' => '二级23'),
4 => array('id' => 4, 'pid' => 9, 'name' => '三级31'),
5 => array('id' => 5, 'pid' => 4, 'name' => '四级43'),
6 => array('id' => 6, 'pid' => 9, 'name' => '三级32'),
7 => array('id' => 7, 'pid' => 4, 'name' => '四级41'),
8 => array('id' => 8, 'pid' => 4, 'name' => '四级42'),
9 => array('id' => 9, 'pid' => 1, 'name' => '二级25'),
10 => array('id' => 10, 'pid' => 11, 'name' => '二级22'),
11 => array('id' => 11, 'pid' => 0, 'name' => '一级12'),
12 => array('id' => 12, 'pid' => 11, 'name' => '二级24'),
13 => array('id' => 13, 'pid' => 4, 'name' => '四级44'),
14 => array('id' => 14, 'pid' => 1, 'name' => '二级26'),
15 => array('id' => 15, 'pid' => 8, 'name' => '五级51'),
16 => array('id' => 16, 'pid' => 8, 'name' => '五级52'),
17 => array('id' => 17, 'pid' => 8, 'name' => '五级53'),
18 => array('id' => 18, 'pid' => 16, 'name' => '六级64'),
);
print_r(genTree($items));
欢迎参与《PHP实战:php两种无限分类方法实例》讨论,分享您的想法,维易PHP学院为您提供专业教程。