Re: [SMARTY] accessing an array var with a variable name

From: Date: Fri, 21 Oct 2005 16:02:18 +0000
Subject: Re: [SMARTY] accessing an array var with a variable name
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-13110@lists.php.net to get a copy of this message
Kathleen Krause-Thompson wrote:
Thank you for help provided in the past. This time, I am using the section tag and would like to access an array using the $smarty.section.name.index variable (see the ??? below). -------------------------------- {section name=ill start=1 loop=$num+1 step=1} <p>Job Title {$smarty.section.ill.index} {if !empty($errors.budget?????.baseSalAmt)}<span id="errortext">{$errors.budget?????.baseSalAmt}</span>{/if} {/section} ---------------------------- ?????? is where I would like for the $smarty.section.ill.index to go, for example {$errors.budget2.baseSalAmt}. How would I access this array variable dynamically?
Iám not sure, but this could work: {section name=ill start=1 loop=$num+1 step=1} <p>Job Title {$smarty.section.ill.index} {if !empty($errors.budget?????.baseSalAmt)} {assign var="index" value=budget$smarty.section.ill.index} <span id="errortext">{$errors.$index.baseSalAmt}</span> {/if} {/section}

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