Re: [SMARTY] looping through variable names
"Cal Henderson" <[email protected]>
| Newsgroups | gmane.comp.php.smarty.general |
|---|---|
| Message-ID | <085d01c5a389$ad0a7d40$0100000a@bodybetweenlx> |
Kathleen Krause-Thompson <[email protected]> wrote: : That doesn't quite answer my question. Here is another posting with : the php. : : <?php : for ($i=1;$i<=$_SESSION['budgetPos'];$i++) { : $str = 'budget' . $i; : if (isset($_SESSION[$str])) { : $smarty->assign($str,$_SESSION[$str]); : } : } change the php: <?php $bits = array(); for ($i=1;$i<=$_SESSION['budgetPos'];$i++) { $str = 'budget' . $i; if (isset($_SESSION[$str])) { $bits[$str] = $_SESSION[$str]; } } $smarty->assign_by_ref('budgets', &$bits); ?> then smarty: {foreach from=$budgets item='budget'} <p>Job Title: {$budget.jobTitle} Percent of Full Time:{$budget.percentFullTime}</p> {/foreach} --cal -- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php