Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

name of var problem

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
daoho
Smarty n00b


Joined: 12 Aug 2003
Posts: 4

PostPosted: Tue Aug 19, 2003 12:16 pm    Post subject: name of var problem Reply with quote

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
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Tue Aug 19, 2003 8:54 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP