| Maximillian Schwanekamp 2005-08-17, 10:02 pm |
| Kathleen Krause-Thomson wrote:
> ...I need to
> loop through array variable names as if they were variable variables.
> How would I do this in Smarty?
> <p>Job Title: {$budget1.jobTitle}
> Percent of Full Time:{$budget1.percentFullTime}</p>
> Next section needs to be:...
From what you gave so far, it seems like you just need to assign your
array $budget, and use {foreach} to iterate over it. E.g.:
<?php
$budgets = array();
$budgets[] = array('jobTitle'=>'First Job', 'percentFullTime'=>100);
$budgets[] = array('jobTitle'=>'Second Job', 'percentFullTime'=>75);
//etc...
?>
{* smarty *}
{foreach from=$budgets item="budget"}
<p>Job Title: {$budget.jobTitle}
Percent of Full Time:{$budget.percentFullTime}</p>
{foreachelse}
<p>No budgets found.</p>
{/foreach}
If that doesn't answer the question, can you post your PHP, and [a
sample of] the array structure?
--
Max Schwanekamp
http://www.neptunewebworks.com/
|