Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Dedicated server web hosting provided by Guru-host.eu.
iterate multidimensional array

 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
camilord
Smarty n00b


Joined: 04 Jun 2012
Posts: 2

PostPosted: Mon Jun 04, 2012 5:09 pm    Post subject: iterate multidimensional array Reply with quote

greetings...

i would like to know how i will iterate this array...

Code:

Array
(
    [0] => Array
        (
            [city_name] => London
            [city_url] => linkhere...
            [schools] => Array
                (
                    [0] => Array
                        (
                            [img_link] => oakdale-college-english-school.html
                            [img_path] => /img/thumbs2/kx front2.jpg
                            [school_name] => Oakdale College English School
                            [star_rating] => ReviewReviewReviewReviewReview
                            [price] => See price
                        )

                    [1] => Array
                        (
                            [img_link] => leicester-square-school-of-english.html
                            [img_path] => /img/thumbs2/leicestersq.jpg
                            [school_name] => Leicester Square School of English
                            [star_rating] => ReviewReviewReviewReviewReview
                            [price] => Courses from  € 23.70
                        )
         )
     ..............
    [2] => Array
        (
            [city_name] => Orvieto
            [city_url] => learn-italian/italy/orvieto/
            [schools] => Array
                (
                    [0] => Array
                        (
                            [img_link] => /oakdale-college-english-school.html
                            [img_path] => /img/thumbs2/kx front2.jpg
                            [school_name] => Oakdale College English School
                            [star_rating] => ReviewReviewReviewReviewReview
                            [price] => See price
                        )

                    [1] => Array
                        (
                            [img_link] => /leicester-square-school-of-english.html
                            [img_path] => /img/thumbs2/leicestersq.jpg
                            [school_name] => Leicester Square School of English
                            [star_rating] => ReviewReviewReviewReviewReview
                            [price] => Courses from  € 23.70
                        )
    ................


as they said, smarty can't do nested... then how i will code this in a template?

please help.. Smile
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 4183
Location: Hamburg / Germany

PostPosted: Mon Jun 04, 2012 7:37 pm    Post subject: Reply with quote

Something like this

Code:

{foreach from=$array item=city}
    {$city.city_name}
     .....
    {foreach from=$city.schools item=school}
        {$school.school_name}
         .....
    {/foreach}
{/foreach}
Back to top
View user's profile Send private message
camilord
Smarty n00b


Joined: 04 Jun 2012
Posts: 2

PostPosted: Mon Jun 04, 2012 9:05 pm    Post subject: Reply with quote

thank you U.Tews... helps a lot.. Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    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