aj123cd Posted March 18, 2012 Share Posted March 18, 2012 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 protected] [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]); Quote Link to comment https://forums.phpfreaks.com/topic/259211-multidimensional-array-how-to-get-specific-values-from-sub-array/ Share on other sites More sharing options...
freelance84 Posted March 18, 2012 Share Posted March 18, 2012 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']; Quote Link to comment https://forums.phpfreaks.com/topic/259211-multidimensional-array-how-to-get-specific-values-from-sub-array/#findComment-1328799 Share on other sites More sharing options...
aj123cd Posted March 18, 2012 Author Share Posted March 18, 2012 Thanks freelance84, is there any best method? cox I have 250 email and name to sort. Quote Link to comment https://forums.phpfreaks.com/topic/259211-multidimensional-array-how-to-get-specific-values-from-sub-array/#findComment-1328801 Share on other sites More sharing options...
aj123cd Posted March 19, 2012 Author Share Posted March 19, 2012 $id = $emp_det[0][id']['$t']; why I can not get id from above code? id there any best way to get the value? Quote Link to comment https://forums.phpfreaks.com/topic/259211-multidimensional-array-how-to-get-specific-values-from-sub-array/#findComment-1328938 Share on other sites More sharing options...
trq Posted March 19, 2012 Share Posted March 19, 2012 Variables are not interpolated within single quotes. You should also receive a parse error because of the missing quotes around id. $id = $emp_det[0]['id'][$t]; Quote Link to comment https://forums.phpfreaks.com/topic/259211-multidimensional-array-how-to-get-specific-values-from-sub-array/#findComment-1328948 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.