Re: variable inside a variable or nested variables

From: Date: Wed, 21 Apr 2004 18:19:20 +0000
Subject: Re: variable inside a variable or nested variables
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-11291@lists.php.net to get a copy of this message
Zilvinas Saltys wrote:
Hello I have this: <?php $langs = (en, ru); $arr = (en => array ('header' => 'a'), ru => array ('header' => 'b')); foreach ($langs as $lang) { $this->tpl->assign($lang, $arr[$lang]); } $this->tpl->assign($langs); ?> In the template i have: {foreach item=row from=$langs} <input type="text" name="{$row}[header]" value="{${$row}.header}" size="30" maxlength="100" /> {/foreach} So the problem appears when i try to use {${$row}.header}... This does not work. Is there a way to access my arrays en[] ru[] from this loop? Thank you Bye
Use something like this: $this->tpl->assign('langs', $arr); {foreach item="row" key="lang" from=$langs } <input type="text" name="{$lang}[header]" value="{$row.header}" size="30" maxlength="100" /> {/foreach} -- paperCrane <Justin Patrin>

« previous php.smarty.general (#11291) next »