Re: [SMARTY] looping through variable names
| From: | Cal Henderson | Date: | Thu, 18 Aug 2005 00:13:33 +0000 |
| Subject: | Re: [SMARTY] looping through variable names | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-12973@lists.php.net to get a copy of this message | ||
Kathleen Krause-Thompson <kkthompson@tsl.state.tx.us> 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