How does smarty cyclically traverse the template to output 3D data ??? Smarty php multi-dimensional array loop
The array structure passed from php.
Array
(
[0] => Array
(
[0] => Array
(
[Id] => 15
[Pid] => 0-2-11
[Name] => Women's clothing
[Href] =>
[Date] =>
)
[1] => Array
(
[Id] => 18
[Pid] => 0-2-11
[Name] => shirt
[Href] =>
[Date] =>
)
[2] => Array
(
[Id] => 40
[Pid] => 0-2-11
[Name] => www
[Href] =>
[Date] =>
)
[3] => Array
(
[Id] => 45
[Pid] => 0-2-11
[Name] => Fei Gonghe
[Href] =>
[Date] =>
)
)
[1] => Array
(
)
[2] => Array
(
[0] => Array
(
[Id] => 43
[Pid] => 0-2-13
[Name] => er
[Href] =>
[Date] =>
)
)
[3] => Array
(
)
[4] => Array
(
)
[5] => Array
(
)
[6] => Array
(
)
[7] => Array
(
[0] => Array
(
[Id] => 41
[Pid] => 0-3-16
[Name] => Who
[Href] =>
[Date] =>
)
)
[8] => Array
(
[0] => Array
(
[Id] => 44
[Pid] => 0-3-21
[Name] => Aston
[Href] =>
[Date] =>
)
)
[9] => Array
(
)
[10] => Array
(
)
[11] => Array
(
)
[12] => Array
(
[0] => Array
(
[Id] => 42
[Pid] => 0-9-38
[Name] => high-tech exhibition hall
[Href] =>
[Date] =>
)
)
)
Reply to discussion (solution)
Smarty foreach
Smarty foreach
I know this, but the 3D array won't get it!
Expected results
Expected results
{foreach item=lop key=k name=loop from=$dao}
{$dao[$k].name} {foreach item=lop2 key=kk name=loop1 from=$dao1} { if $k==$kk && $dao1[$kk]|@count neq 0}
{foreach item=lop3 key=kkk from=$lop2}
- {$lop3.name}{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}
{/if}
- {$lop5.name}
{if $smarty.foreach.app.iteration==$lop4|@count}
{/if}{/if}{/foreach}{/if}{/foreach} {/foreach}
{/if}{/foreach}{/foreach}