How does smarty cyclically traverse the template to output 3D data ???

Source: Internet
Author: User
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}

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.