Jump to content

Multidimensional Array Help


christo16

Recommended Posts

Hello I am working with the facebook api and it produces requests as an array, like so:

Array
(
    [ 0] => Array
        (
            [uid] => 11701055
            [ affiliations ] => Array
                (
                    [ 0 ] => Array
                        (
                            [nid] => 1234567
                            [name] => XXXX
                            [type] => college
                            [status] => Undergrad
                            [year] => 2008
                        )

                    [1] => Array
                        (
                            [nid] => 12233566
                            [name] => Test
                            [type] => work
                            [status] => 
                            [year] => 0
                        )

                    [2] => Array
                        (
                            [nid] => 12344665
                            [name] => Anytown, CA
                            [type] => region
                            [status] => 
                            [year] => 0
                        )

                )

        )

)

How would I pull out a single part of the array such as:

affiliations to  0  to Type, which would be "college"

I've tried many different ways and still no luck :(

Any help is appreciated!

Thank you!!!!

Link to comment
https://forums.phpfreaks.com/topic/63211-multidimensional-array-help/
Share on other sites

$array[0]['affiliations'][0]['type']

 

all you need are the various keys, and you can specify as low down in the array tree as you like.  separate keys by square brackets, as usual.

 

PS:  in future, to help us keep this place neat and tidy, please use code tags for any code or code output.  thanks.

Archived

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

×
×
  • Create New...

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.