|
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 |
daoho Smarty n00b
Joined: 12 Aug 2003 Posts: 4
|
Posted: Tue Aug 19, 2003 12:16 pm Post subject: name of var problem |
|
|
hello !
I have the var $table wich is an array of strings (for example "test1"-"test2"-"test3")
Then I have the var $arraytest1 , $arraytest2 and $arraytest3 wich are arrays with a lot of information.
I finally want to do something like that:
$myarray = $("array".$table) (in fact a cat of the name, not a cat of the value of the var)
How is it possible to write that in smarty ???
Thanks a lot |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Tue Aug 19, 2003 8:54 pm Post subject: |
|
|
IFAIK, Smarty doesn't have a convenient way of doing this, though you can use an assigned {capture} to hack something out. Why not store your vars $arraytest1,... etc in an associateive array instead of separately assigned vars?
ie. $allinfo=array('test1'=>array(...), 'test2'=>array(...),...);
That way you can pass the array to Smarty and then use the more typical {foreach} or dot-notation for arrays to access your required data. eg. Instead of {$arraytest1}, you could do {$allinfo.test1} etc. |
|
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
|