How to assign an array within a smarty template file?

前端 未结 5 694
萌比男神i
萌比男神i 2020-12-09 07:53

I was wondering if it was possible to assign an array to a variable within a Smarty template file? I have tried this

{assign var=\'file\' value = array(\'dir         


        
5条回答
  •  不知归路
    2020-12-09 07:59

    {php}
      $this->assign("array", array('dir','doc','exe'));
    {/php}
    
    {foreach from=$array item=item}
      {$item}
    {/foreach}
    

    From Smarty v.3 new syntax is available

    {$array = ['item1','item2',$item3]}
    

    see for more details : http://www.smarty.net/docs/en/language.syntax.variables.tpl

提交回复
热议问题