简体   繁体   中英

How to write array with index in Smarty

how can I write this line :

$value['description'][0]

in Smarty?

I tried to write it in this way :

{$value.description[0]}

But it's not working.

你需要这个

{$value.description.0}

you can use this on smarty

{foreach from=$value key=k item=v}
   <li>{$k}: {$v}</li>
{/foreach}

In fact you can do it either using dot operator:

{$value.description.0}

or using PHP-like syntax:

{$value['description'][0]}

Both will work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM