Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

How can I walk through 2 arrays?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
Antoine
Smarty n00b


Joined: 29 Jul 2003
Posts: 4

PostPosted: Sun Aug 03, 2003 3:29 pm    Post subject: How can I walk through 2 arrays? Reply with quote

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
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Mon Aug 11, 2003 10:14 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP