Heim  >  Artikel  >  Backend-Entwicklung  >  smarty模板解析数组有关问题

smarty模板解析数组有关问题

WBOY
WBOYOriginal
2016-06-13 10:18:17806Durchsuche

smarty模板解析数组问题

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->array (  'id' => 1,  'pid' => 0,  'name' => '一级1',  'child' =>   array (    2 =>     array (      'id' => 2,      'pid' => 1,      'name' => '二级11',    ),    3 =>     array (      'id' => 3,      'pid' => 1,      'name' => '二级12',    ),    9 =>     array (      'id' => 9,      'pid' => 1,      'name' => '二级13',      'child' =>       array (        4 =>         array (          'id' => 4,          'pid' => 9,          'name' => '三级11',          'child' =>           array (            5 =>             array (              'id' => 5,              'pid' => 4,              'name' => '四级13',            ),            7 =>             array (              'id' => 7,              'pid' => 4,              'name' => '四级11',            ),            8 =>             array (              'id' => 8,              'pid' => 4,              'name' => '四级12',              'child' =>               array (                10 =>                 array (                  'id' => 10,                  'pid' => 8,                  'name' => '五级分类',                  'child' =>                   array (                    11 =>                     array (                      'id' => 11,                      'pid' => 10,                      'name' => '六级分类',                    ),                  ),                ),              ),            ),          ),        ),        6 =>         array (          'id' => 6,          'pid' => 9,          'name' => '三级21',        ),      ),    ),  ),)


这种数组在smarty里怎么做处理成树状结构??

------解决方案--------------------
是用JS做的吧,如果smarty能做,那么PHP就能
------解决方案--------------------
我想知道干嘛
------解决方案--------------------
smarty2 不可以
smarty3 可以,模板中又递归函数
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn