Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.