Hello.聖誕快樂!
我有資料結構如下:
0 =>
array (size=13)
'id' => string '46' (length=2)
'name' => string 'Test' (length=9)
'parent_id' => string '1' (length=1)
'son' =>
array (size=2)
0 =>
array (size=13)
...
1 =>
array (size=12)
...
1 =>
array (size=13)
'id' => string '914' (length=3)
'name' => string '测试2' (length=9)
'parent_id' => string '0' (length=1)
'son' =>
array (size=3)
0 =>
array (size=12)
...
1 =>
array (size=12)
...
2 =>
array (size=12)
...
我要怎麼畫一棵樹呢?
<li>
<p class="tree_title">
<img src="images/px_02.png" class="icon_btn"/>
<label class="title">一级</label>
<input type="checkbox" class="view">
<input type="checkbox" class="manage">
</p>
<ul class="space">
<li>
<p class="tree_title">
<img src="images/px_02.png" class="icon_btn"/>
<lavel class="title">二级</lavel>
<input type="checkbox" class="view">
<input type="checkbox" class="manage">
</p>
<ul class="space">
<li>
<p class="tree_title">
<img src="images/px_02.png" class="icon_btn"/>
<label class="title">三级</label>
<input type="checkbox" class="view">
<input type="checkbox" class="manage">
</p>
</li>
</ul>
</li>
</ul>
</li>
想了好久沒想出來,其中array的son代表它的子節點。 。 。
人生最曼妙的风景,竟是内心的淡定与从容!