smarty php 多维数组循环
这个从php传过来的数组结构。
Array
(
[0] => Array
(
[0] => Array
(
[id] => 15
[pid] => 0-2-11
[name] => 女装
[href] =>
[date] =>
)
[1] => Array
(
[id] => 18
[pid] => 0-2-11
[name] => 衬衣
[href] =>
[date] =>
)
[2] => Array
(
[id] => 40
[pid] => 0-2-11
[name] => www
[href] =>
[date] =>
)
[3] => Array
(
[id] => 45
[pid] => 0-2-11
[name] => 费共和
[href] =>
[date] =>
)
)
[1] => Array
(
)
[2] => Array
(
[0] => Array
(
[id] => 43
[pid] => 0-2-13
[name] => 呃呃
[href] =>
[date] =>
)
)
[3] => Array
(
)
[4] => Array
(
)
[5] => Array
(
)
[6] => Array
(
)
[7] => Array
(
[0] => Array
(
[id] => 41
[pid] => 0-3-16
[name] => 呜呜呜
[href] =>
[date] =>
)
)
[8] => Array
(
[0] => Array
(
[id] => 44
[pid] => 0-3-21
[name] => 阿斯顿
[href] =>
[date] =>
)
)
[9] => Array
(
)
[10] => Array
(
)
[11] => Array
(
)
[12] => Array
(
[0] => Array
(
[id] => 42
[pid] => 0-9-38
[name] => 高交会馆
[href] =>
[date] =>
)
)
)
回复讨论(解决方案)
smarty foreach
smarty foreach
这个我知道,但是三维数组不会弄!
要的这种效果
要的这种效果
{foreach item=lop key=k name=loop from=$dao} <li {if $lop.id==10}class="wu"{/if}><a href="{$lop.href}">{$dao[$k].name}</a> {foreach item=lop2 key=kk name=loop1 from=$dao1} { if $k==$kk && $dao1[$kk]|@count neq 0} <ul> {foreach item=lop3 key=kkk from=$lop2} <li><a href="">{$lop3.name}</a> {foreach item=lop4 key=kkkk from=$dao2} {if $dao2[$kkk]|@count neq 0} {foreach item=lop5 name=app key=kkkkk from=$lop4} {if $lop5.pid===$lop3.pid|cat:"-"|cat:$lop3.id} {if $smarty.foreach.app.index==0}<ul>{/if} <li><a href="#">{$lop5.name}</a></li> {if $smarty.foreach.app.iteration==$lop4|@count} </ul>{/if} {/if} {/foreach} {/if} {/foreach} </li> {/foreach} </ul> {/if} {/foreach} </li> {/foreach}