码迷,mamicode.com
首页 > 其他好文 > 详细

不遗留问题-menu数据拼装-2

时间:2016-10-03 23:17:45      阅读:256      评论:0      收藏:0      [点我收藏+]

标签:

 1 $res = array();
 2 foreach($idlist_1 as $id1)
 3 {
 4     $tmp = array();
 5     $tmp1 = array();
 6     $tmp1[] = $id1;
 7     foreach($idlist_2 as $id2)
 8     {
 9         $tmp2 = array();
10         if(get_parentid($id2)==$id1)
11         {
12             $tmp2[] = $id2;
13             $tmp3 = array();
14             foreach($idlist_3 as $id3)
15             {
16                 if(get_parentid($id3)==$id2) $tmp3[]=$id3;
17             }
18             $tmp2[] =  $tmp3;
19             $tmp1[] = $tmp2;
20         }
21     }
22     $res[] = $tmp1;
23 }
  1 Array
  2 (
  3     [0] => Array
  4         (
  5             [0] => 1
  6             [1] => Array
  7                 (
  8                     [0] => 4
  9                     [1] => Array
 10                         (
 11                             [0] => 13
 12                             [1] => 14
 13                             [2] => 15
 14                         )
 15 
 16                 )
 17 
 18             [2] => Array
 19                 (
 20                     [0] => 5
 21                     [1] => Array
 22                         (
 23                             [0] => 16
 24                             [1] => 17
 25                             [2] => 18
 26                         )
 27 
 28                 )
 29 
 30             [3] => Array
 31                 (
 32                     [0] => 6
 33                     [1] => Array
 34                         (
 35                             [0] => 19
 36                             [1] => 20
 37                             [2] => 21
 38                         )
 39 
 40                 )
 41 
 42         )
 43 
 44     [1] => Array
 45         (
 46             [0] => 2
 47             [1] => Array
 48                 (
 49                     [0] => 7
 50                     [1] => Array
 51                         (
 52                             [0] => 22
 53                             [1] => 23
 54                             [2] => 24
 55                         )
 56 
 57                 )
 58 
 59             [2] => Array
 60                 (
 61                     [0] => 8
 62                     [1] => Array
 63                         (
 64                             [0] => 25
 65                             [1] => 26
 66                             [2] => 27
 67                         )
 68 
 69                 )
 70 
 71             [3] => Array
 72                 (
 73                     [0] => 9
 74                     [1] => Array
 75                         (
 76                             [0] => 28
 77                             [1] => 29
 78                             [2] => 30
 79                         )
 80 
 81                 )
 82 
 83         )
 84 
 85     [2] => Array
 86         (
 87             [0] => 3
 88             [1] => Array
 89                 (
 90                     [0] => 10
 91                     [1] => Array
 92                         (
 93                             [0] => 31
 94                             [1] => 32
 95                             [2] => 33
 96                         )
 97 
 98                 )
 99 
100             [2] => Array
101                 (
102                     [0] => 11
103                     [1] => Array
104                         (
105                             [0] => 34
106                             [1] => 35
107                             [2] => 36
108                         )
109 
110                 )
111 
112             [3] => Array
113                 (
114                     [0] => 12
115                     [1] => Array
116                         (
117                             [0] => 37
118                             [1] => 38
119                             [2] => 39
120                         )
121 
122                 )
123 
124         )
125 
126 )

 

不遗留问题-menu数据拼装-2

标签:

原文地址:http://www.cnblogs.com/yuanjiangw/p/5929649.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!