Smarty assigns value to index of array variable

I am using SMARTY and I need to create an array and assign a value to its specific index.

Sort of:

{foreach from=$a key='i' item='b'}
//Some calculations here giving me a VALUE
ARRAY[$i] = $VALUE;
{/foreach}

Now the problem is that I'm using the standard Smarty Assign syntax

{assign var='array.$i' value=$VALUE}
{assign var='array[$i]' value=$VALUE}
{assign var=$array.$i value=$VALUE}
{assign var='$array[$i]' value=$VALUE}

does not work. I need to use this array later in the code, and therefore, I need it only in array format

+3
source share
1 answer

Have you tried to assign an abridged version instead ?

{$array.$i = $VALUE}
+10
source

All Articles