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

Multidimensional arrays - once again

 
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
yag
Smarty n00b


Joined: 22 Aug 2004
Posts: 1

PostPosted: Sun Aug 22, 2004 4:40 pm    Post subject: Multidimensional arrays - once again Reply with quote

Hello everyone,
I've searched the forums and found some similar problems with solutions, and I've tried to work it out, but it just not going to happen I guess. Here is my problem. I pass an array like the one below to smarty:

Code:

Array
(
    [2] => Array
        (
            [scores] => Scores
            [add] => Enter_scores
            [check] => Check_scores
        )

)
Array
(
    [8] => Array
        (
            [players] => Players
            [add] => Add_players
            [edit] => Edit_players_data
            [remove] => Remove_player
        )

)
Array
(
    [9] => Array
        (
            [teams] => Teams
            [add] => Add_teams
            [edit] => Edit_teams_data
            [remove] => Remove_teams
        )

)


And I want to create something like this (some kind of menu):
Code:

* Scores
---- Enter_scores
---- Check_scores
* Players
---- Add
---- Edit
---- Remove
* Teams
---- Add
---- Edit
---- Remove


This array is created dynamically, by taking the data out of the MySQL database.

Can anyone help me? Maybe I need to create this array in some other way to get it working?
Back to top
View user's profile Send private message
dthought
Smarty Regular


Joined: 21 Apr 2003
Posts: 55
Location: Melbourne, Australia

PostPosted: Wed Aug 25, 2004 7:12 am    Post subject: Reply with quote

You can get around that with a foreach. Because your keys do not start with 0 and are not necessarily sequential, foreach is your answer Smile
Back to top
View user's profile Send private message Visit poster's website
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