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

Problem with multidimensional 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
Chavez
Smarty Rookie


Joined: 08 Jul 2003
Posts: 6

PostPosted: Wed Jul 09, 2003 1:06 pm    Post subject: Problem with multidimensional arrays Reply with quote

Hi!

I pass this array to Smarty with $smarty->assign('company_output', $company_output);

Code:
Array
(
    [sv] => Array
        (
            [0] => Array
                (
                    [id] => 9
                    [name] => aFirstName
                    [homesite] => http://www25.something.com
                    [info] => ...
                    [date] => 1052738803
                )

            [1] => Array
                (
                    [id] => 7
                    [name] => aName
                    [homesite] => http://www.adomain.com/
                    [info] => Some information
                    [date] => 1040075691
                )

        )

    [no] => Array
        (
            [0] => Array
                (
                    [id] => 13
                    [name] => aName
                    [homesite] => http://www.adomain.se/
                    [info] => Some information
                    [date] =>
                )

        )

)


I'm trying to parse this in my template using a nested section like this:

Code:
{section name=langboxid loop=$company_output}
Some HTML...
 {section name=companyid loop=$company_output[langboxid]}
Some HTML..
 {/section}
 {/section}


Whats wrong? The first section (langboxid) seems to work fine but my inner section doesen't get parsed at all. Ideas?
Back to top
View user's profile Send private message
Chavez
Smarty Rookie


Joined: 08 Jul 2003
Posts: 6

PostPosted: Wed Jul 09, 2003 1:17 pm    Post subject: Reply with quote

I have tried to use {foreach} as well, but there seems to be some stupid mistake from my side cause I can't get that to work either Smile
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed Jul 09, 2003 3:00 pm    Post subject: Reply with quote

section doesn't work here, because you have "sv" and "no" as keys and not "0" and "1"


maybe:

Code:

{foreach from=$company_output key=langboxid item=compay }
   {foreach from=$company key=name item=value}
{$name} => {$value}
   {/foreach}
{/foreach}


???
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Chavez
Smarty Rookie


Joined: 08 Jul 2003
Posts: 6

PostPosted: Wed Jul 09, 2003 3:19 pm    Post subject: Reply with quote

Hi!

Thanks a lot! Of course it worked just the way I wanted.
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