I want to create an array in smarty and do an append functionality in it! Like if I declare a variable in smarty template like {assign var=sizearr value=''}
and then i want to append values to this in a loop, and i can access values like {sizearr.0}
, how can i do that?
Use append. I'm not sure if this is also available in Smarty 2
{append var='sizearr' value='' index=0}
In smarty3 yould also use a more php-like approach:
{$sizearr[] = 'your value'}
and either loop through the array like
{foreach $sizearr as $value}
{$value@key}: {$value}
{/foreach}
or just hit a specific index:
{$sizearr[2]}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With