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

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.