5

I am using SMARTY and I need to create an array and assign value to a particular index of it.

Something like:

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

Now the problem is when I am using 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}

its not working. I need to use this array later in the code and hence need it in an array format only

1 Answer 1

15

Have you tried the assign shorthand instead?

{$array.$i = $VALUE}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.