I have a simple question. I need to append 1,2,3 etc to a variable name in smarty. The variables are $user1, $user2, $user3 etc. I use smarty to do a simple loop like this:
{section name=user_info start=1 loop=$users}
<tr>
<td> User{$smarty.section.user_info.index} </td> // prints user1, user2, user3 etc
<td>
{$user} append this: {$smarty.section.user_info.index} // need to call $userX
</td>
</tr>
{/section}
I tried everything on the variable info site to smarty.
Make
$usera numerically index array instead of declaring a variable for each user as you have now ($user1, $user2, $user3) and then you can use:According to Smarty Variables manual
Once converted this would be like:
So in your case it would be
{$user.$smarty.section.user_info.index}.