Jump to content

Archived

This topic is now archived and is closed to further replies.

Pythondesigns

Help with array *SOLVED*

Recommended Posts

Hey,

I have an array like this which is called $CFG.

[quote]Array
(
    [online] => 1
    [sitename] => MySite
    [indexurl] => http://mysite.com
    [areas] => Array
        (
            [home] => Array
                (
                    [id] => 1
                    [text] => Home
                    [order] => 0
                    [navshow] => 1
                )

            [profile] => Array
                (
                    [id] => 2
                    [text] => Profile
                    [order] => 1
                    [navshow] => 1
                )

            [jobs] => Array
                (
                    [id] => 3
                    [text] => Jobs
                    [order] => 3
                    [navshow] => 1
                )

            [business] => Array
                (
                    [id] => 4
                    [text] => Business
                    [order] => 4
                    [navshow] => 1
                )

            [finance] => Array
                (
                    [id] => 5
                    [text] => Finance
                    [order] => 5
                    [navshow] => 1
                )

        )

)[/quote]

As you can see the $CFG[areas] is another array. And then within each again is an array.

Basically each of the values inside the $CFG[areas] are links for a menu Im making and what I want to do is to cycle through them all (theres 5 of them) and display its relevant id.

So at the end I want this...

[quote]Home (which links to homes id)
Profile (which links to profiles id)
Jobs (which links to jobs id)
And so on...[/quote]

How can I do this?

Thanks

Share this post


Link to post
Share on other sites
[code]foreach ($CFG['areas] as $key => $data) {
    echo "$key : {$data['id']} <br/>";
}

[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.