My PHP code assigns an array to a Smarty variable that can be accessed in the following way:
{$foo.123.name}
{$foo.456.name}
...
The 123
, 456
, etc. indexes in the array are dynamically assigned (based on some logic that includes the database). Since they are dynamically assigned, I cannot just put 123
, etc. in the template file. However, those numbers are in another Smarty variable, say:
{$bar.id}
How do I use this $bar.id
in place of the 123
, 456
?
For Smarty3:
{$foo.{$bar.id}.name}
For Smarty2:
{assign var="bid" value=$bar.id}
{$foo.$bid.name}