Jump to content

Multidimensional array - how to get specific values from sub array


aj123cd

Recommended Posts

I have the following  array structure:


[0] => Array
        (
            [id] => Array
                (
                    [$t] => http://www.google.com/mate/
                )

            [updated] => Array
                (
                    [$t] => 2011-08-31T11:43:05.942Z
                )

            [category] => Array
                (
                    [0] => Array
                        (
                            [scheme] => http://schemas.google.com/g/
                            [term] => http://schemas.google.com/contact/
                        )

                )

            [title] => Array
                (
                    [type] => text
                    [$t] => Name
                )

            [link] => Array
                (
                    [0] => Array
                        (
                            [rel] => http://schemas.google.com/contacts/2008/rel#edit-photo
                            [type] => image/*
                            [href] => https://www.google.com/mate/feeds/photos/media/
                        )

                    [1] => Array
                        (
                            [rel] => self
                            [type] => application/atom+xml
                            [href] => https://www.google.com/mate/feeds/contacts
                        )

                    [2] => Array
                        (
                            [rel] => edit
                            [type] => application/atom+xml
                            [href] => https://www.google.com/mate/feeds/
                        )

                )

            [gd$email] => Array
                (
                    [0] => Array
                        (
                            [rel] => http://schemas.google.com/g/2005#other
                            [address] => email_address@gmail.com
                            [primary] => true
                        )

                )

        )


 

I am tried to display name and email address.

I am using following method, can anyone tell me is there any better way? Thank u 4u help.

NAME

$name=( $emp_det[0]['title'][t]);

EMAIL

$email =( $emp_det[0]['gdemail'][0][address]);

 

Link to comment
Share on other sites

NAME

$name=( $emp_det[0]['title'][t]);

In your array t is $t.. if it is actuall t then this should work:

$name = $emp_det[0]['title']['t'];

 

 

EMAIL

$email =( $emp_det[0]['gdemail'][0][address]);

Again In your array gdemail is gd$email, if it is actually gdemail, this this should work:

$email =$emp_det[0]['gdemail'][0]['address'];

Link to comment
Share on other sites

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.