RE: [SMARTY] Getting a value from an array using a variable as reference
| From: | Javier Tacon | Date: | Tue, 16 Sep 2003 09:58:26 +0000 |
| Subject: | RE: [SMARTY] Getting a value from an array using a variable as reference | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-10223@lists.php.net to get a copy of this message | ||
Yesterday I wrote this answer to a similar question, I hope this helps you.
-----Mensaje original-----
De: Javier Tacon
Enviado el: lunes, 15 de septiembre de 2003 15:56
Para: Thomas Pilgaard Miller; smarty-general@lists.php.net
Asunto: RE: [SMARTY] Getting a value from an array using a variable as
reference
Humm, try with something like this, it should work:
test.php
$S = new Smarty();
$SessionVars["key1"]["grp_id"]="value";
$MenuItem["ThisStep"]="key1";
$S->assign('MenuItem',$MenuItem);
$S->assign('SessionVars',$SessionVars);
$S->display('test.tpl');
test.tpl
{assign var=tmpKey value=$MenuItem.ThisStep}
Key: {$tmpKey} <- (ke1)
Result: {$SessionVars.$tmpKey.grp_id} <- (value)
-----Mensaje original-----
De: Thomas Pilgaard Miller [mailto:ascii@microcore.dk]
Enviado el: lunes, 15 de septiembre de 2003 15:12
Para: smarty-general@lists.php.net
Asunto: [SMARTY] Getting a value from an array using a variable as
reference
Hi list,
I have such a hard time figuring out how to achieve the following:
{$SessionVars[$MenuItem.ThisStep].grp_id}
The problem is that it won't compile.
I am trying to retrieve the value from $SessionVars['Position'].grp_id
by the use of $MenuItem.ThisStep
Can anyone tell me how to go about this.
Any help is appreciated.
Thanks in advance,
Thomas
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php