|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
redbrad0 Smarty Regular
Joined: 03 Feb 2007 Posts: 41
|
Posted: Wed Dec 15, 2021 8:37 pm Post subject: using a variable as part of another variable name to get val |
|
|
I have a variable that I can output the contents with {$Price_5056} to get the value but I would like to replace 5056 with another variable like {$Price_{$pricelevel.ID}} but I keep getting errors. Is there something I am doing wrong?
I am using Smarty 3.1.14 |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sat Dec 18, 2021 6:39 am Post subject: |
|
|
Use arrays already. |
|
Back to top |
|
bsmither Smarty Elite
Joined: 20 Dec 2011 Posts: 322 Location: West Coast
|
Posted: Sun Dec 19, 2021 5:25 am Post subject: |
|
|
Works for me: Smarty 3.1.33.
PHP: Code: | $pricelevel['ID'] = "5056";
$smarty->assign("Price_5056", "999");
$smarty->assign("pricelevel", $pricelevel); | Smarty: Code: | {$Price_5056}<br />
{$Price_{$pricelevel.ID}} | Result:What is the error that you get? |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|