|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Antoine Smarty n00b
Joined: 29 Jul 2003 Posts: 4
|
Posted: Sun Aug 03, 2003 3:29 pm Post subject: How can I walk through 2 arrays? |
|
|
Hello,
I can't figure out how to walk through two arrays in the Smarty Template....
php code:
Code: |
...
$status[$i][$y]=$array_status[$i][6][$y];
...
|
Smarty Template:
Code: |
...
{foreach from=$svar_status item=state name=info}
Print status here {$state}<br>
{/foreach}
...
|
Output would be
Print status here Array.
Yes, this is an array and usually I would use {state[0]} to go through the array, but this would go only through one..
Is there something like a for-loop?
Thanks
Antoine |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Mon Aug 11, 2003 10:14 pm Post subject: |
|
|
Hi Antoine.
You have to iterate each dimension of the array:
Using {foreach}:
Code: | {foreach from=$svar_status item=state name=info}
{foreach from=$state item=state_info}
Print status here {$state_info}<br>
{/foreach}
{/foreach} |
Alternatively, you can use {section} to emulate a for loop as described in the manual http://smarty.php.net/manual/en/language.function.section.php. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|