Smarty: How to reference to the associative array index

前端 未结 4 914
迷失自我
迷失自我 2020-12-29 08:01
Array $imagelist:

Array ( 
    [additional] => Array ( 
        [count] => 2 
        [image] => Array ( 
            [nokia_e61_1.jpg] => Array ( 
             


        
4条回答
  •  情深已故
    2020-12-29 08:43

    I don't like smarty for this, nevertheless I use it. Here's extract form documentation

    {$foo.$bar}   <-- display variable key value of an array, similar to PHP $foo[$bar]
    

    To be able to do it, you have to

    {assign var='key' value=$getvars.imagename}
    {$imagelist.additional.image.$key.name_body}
    

    Hope it helps

提交回复
热议问题