Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

PHP - How to select value by key from large associative array

Avatar of Spiderstave
Spiderstave asked on
Web DevelopmentPHP
12 Comments1 Solution283 ViewsLast Modified:
Hi everyone,

I have a large associative array I'm trying to process. I only need two values, but every time I attempt to pull a value by key, or use a foreach loop to iterate through the array I keep getting errors. I'm a bit new to PHP, so I think the issue is just my syntax. Can anyone help me create the correct syntax?

All I need are two values from the array below, the values for [title] and [video_url]. Any help is appreciated!

Array ( [114] => stdClass Object ( [vid] => 114 [uid] => 1 [title] => Test Video 1 [log] => [status] => 1 [comment] => 2 [promote] => 1 [sticky] => 0 [nid] => 114 [type] => video [language] => und [created] => 1341715638 [changed] => 1341715638 [tnid] => 0 [translate] => 0 [revision_timestamp] => 1341715638 [revision_uid] => 1 [field_video_url] => Array ( [und] => Array ( [0] => Array ( [video_url] => http://www.youtube.com/embed/TO0bIwwLVYI [thumbnail_path] => public://video_embed_field_thumbnails/youtube/TO0bIwwLVYI.jpg [video_data] => a:20:{s:5:"xmlns";s:27:"http://www.w3.org/2005/Atom";s:11:"xmlns$media";s:29:"http://search.yahoo.com/mrss/";s:8:"xmlns$gd";s:32:"http://schemas.google.com/g/2005";s:8:"xmlns$yt";s:37:"http://gdata.youtube.com/schemas/2007";s:7:"gd$etag";s:28:"W/"AkUCRX47eCp7I2A9WhVRF0U."";s:2:"id";s:38:"tag:youtube.com,2008:video:TO0bIwwLVYI";s:9:"published";s:24:"2012-03-26T18:55:42.000Z";s:7:"updated";s:24:"2012-03-26T18:57:44.000Z";s:8:"category";a:4:{i:0;a:2:{s:6:"scheme";s:37:"http://schemas.google.com/g/2005#kind";s:4:"term";s:43:"http://gdata.youtube.com/schemas/2007#video";}i:1;a:3:{s:6:"scheme";s:52:"http://gdata.youtube.com/schemas/2007/categories.cat";s:4:"term";s:9:"Nonprofit";s:5:"label";s:21:"Nonprofits & Activism";}i:2;a:2:{s:6:"scheme";s:50:"http://gdata.youtube.com/schemas/2007/keywords.cat";s:4:"term";s:8:"Passover";}i:3;a:2:{s:6:"scheme";s:50:"http://gdata.youtube.com/schemas/2007/keywords.cat";s:4:"term";s:4:"2012";}}s:5:"title";s:37:"Something to Contribute this Passover";s:7:"content";a:2:{s:4:"type";s:29:"application/x-shockwave-flash";s:3:"src";s:73:"http://www.youtube.com/v/TO0bIwwLVYI?version=3&f=videos&app=youtube_gdata";}s:4:"link";a:6:{i:0;a:3:{s:3:"rel";s:9:"alternate";s:4:"type";s:9:"text/html";s:4:"href";s:64:"http://www.youtube.com/watch?v=TO0bIwwLVYI&feature=youtube_gdata";}i:1;a:3:{s:3:"rel";s:53:"http://gdata.youtube.com/schemas/2007#video.responses";s:4:"type";s:20:"application/atom+xml";s:4:"href";s:67:"http://gdata.youtube.com/feeds/api/videos/TO0bIwwLVYI/responses?v=2";}i:2;a:3:{s:3:"rel";s:51:"http://gdata.youtube.com/schemas/2007#video.related";s:4:"type";s:20:"application/atom+xml";s:4:"href";s:65:"http://gdata.youtube.com/feeds/api/videos/TO0bIwwLVYI/related?v=2";}i:3;a:3:{s:3:"rel";s:44:"http://gdata.youtube.com/schemas/2007#mobile";s:4:"type";s:9:"text/html";s:4:"href";s:42:"http://m.youtube.com/details?v=TO0bIwwLVYI";}i:4;a:3:{s:3:"rel";s:46:"http://gdata.youtube.com/schemas/2007#uploader";s:4:"type";s:20:"application/atom+xml";s:4:"href";s:67:"http://gdata.youtube.com/feeds/api/users/oYqzUf3k0FaTRznc8RZD1g?v=2";}i:5;a:3:{s:3:"rel";s:4:"self";s:4:"type";s:20:"application/atom+xml";s:4:"href";s:57:"http://gdata.youtube.com/feeds/api/videos/TO0bIwwLVYI?v=2";}}s:6:"author";a:1:{i:0;a:3:{s:4:"name";s:15:"jewishinseattle";s:3:"uri";s:56:"http://gdata.youtube.com/feeds/api/users/jewishinseattle";s:9:"yt$userId";s:22:"oYqzUf3k0FaTRznc8RZD1g";}}s:16:"yt$accessControl";a:8:{i:0;a:2:{s:6:"action";s:7:"comment";s:10:"permission";s:7:"allowed";}i:1;a:2:{s:6:"action";s:11:"commentVote";s:10:"permission";s:7:"allowed";}i:2;a:2:{s:6:"action";s:12:"videoRespond";s:10:"permission";s:9:"moderated";}i:3;a:2:{s:6:"action";s:4:"rate";s:10:"permission";s:7:"allowed";}i:4;a:2:{s:6:"action";s:5:"embed";s:10:"permission";s:7:"allowed";}i:5;a:2:{s:6:"action";s:4:"list";s:10:"permission";s:7:"allowed";}i:6;a:2:{s:6:"action";s:8:"autoPlay";s:10:"permission";s:7:"allowed";}i:7;a:2:{s:6:"action";s:9:"syndicate";s:10:"permission";s:7:"allowed";}}s:11:"gd$comments";a:1:{s:11:"gd$feedLink";a:3:{s:3:"rel";s:46:"http://gdata.youtube.com/schemas/2007#comments";s:4:"href";s:66:"http://gdata.youtube.com/feeds/api/videos/TO0bIwwLVYI/comments?v=2";s:9:"countHint";i:0;}}s:5:"yt$hd";a:0:{}s:11:"media$group";a:14:{s:14:"media$category";a:1:{i:0;s:9:"Nonprofit";}s:13:"media$content";a:3:{i:0;a:7:{s:3:"url";s:73:"http://www.youtube.com/v/TO0bIwwLVYI?version=3&f=videos&app=youtube_gdata";s:4:"type";s:29:"application/x-shockwave-flash";s:6:"medium";s:5:"video";s:9:"isDefault";s:4:"true";s:10:"expression";s:4:"full";s:8:"duration";i:74;s:9:"yt$format";i:5;}i:1;a:6:{s:3:"url";s:95:"rtsp://v7.cache3.c.youtube.com/CiILENy73wIaGQmCVQsMIxvtTBMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp";s:4:"type";s:10:"video/3gpp";s:6:"medium";s:5:"video";s:10:"expression";s:4:"full";s:8:"duration";i:74;s:9:"yt$format";i:1;}i:2;a:6:{s:3:"url";s:95:"rtsp://v1.cache4.c.youtube.com/CiILENy73wIaGQmCVQsMIxvtTBMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp";s:4:"type";s:10:"video/3gpp";s:6:"medium";s:5:"video";s:10:"expression";s:4:"full";s:8:"duration";i:74;s:9:"yt$format";i:6;}}s:12:"media$credit";a:1:{i:0;s:15:"jewishinseattle";}s:17:"media$description";s:248:"From early childhood education, to JCCs and summer camps, to senior homes and congregations. Wherever you find joy and caring and Jewish values, that's where you'll find the Jewish Federation. We all have something BIG to contribute this Passover.";s:14:"media$keywords";s:14:"Passover, 2012";s:13:"media$license";s:7:"youtube";s:12:"media$player";a:1:{s:3:"url";s:71:"http://www.youtube.com/watch?v=TO0bIwwLVYI&feature=youtube_gdata_player";}s:15:"media$thumbnail";a:6:{i:0;a:5:{s:3:"url";s:45:"http://i.ytimg.com/vi/TO0bIwwLVYI/default.jpg";s:6:"height";i:90;s:5:"width";i:120;s:4:"time";s:8:"00:00:37";s:7:"yt$name";s:7:"default";}i:1;a:4:{s:3:"url";s:47:"http://i.ytimg.com/vi/TO0bIwwLVYI/mqdefault.jpg";s:6:"height";i:180;s:5:"width";i:320;s:7:"yt$name";s:9:"mqdefault";}i:2;a:4:{s:3:"url";s:47:"http://i.ytimg.com/vi/TO0bIwwLVYI/hqdefault.jpg";s:6:"height";i:360;s:5:"width";i:480;s:7:"yt$name";s:9:"hqdefault";}i:3;a:5:{s:3:"url";s:39:"http://i.ytimg.com/vi/TO0bIwwLVYI/1.jpg";s:6:"height";i:90;s:5:"width";i:120;s:4:"time";s:12:"00:00:18.500";s:7:"yt$name";s:5:"start";}i:4;a:5:{s:3:"url";s:39:"http://i.ytimg.com/vi/TO0bIwwLVYI/2.jpg";s:6:"height";i:90;s:5:"width";i:120;s:4:"time";s:8:"00:00:37";s:7:"yt$name";s:6:"middle";}i:5;a:5:{s:3:"url";s:39:"http://i.ytimg.com/vi/TO0bIwwLVYI/3.jpg";s:6:"height";i:90;s:5:"width";i:120;s:4:"time";s:12:"00:00:55.500";s:7:"yt$name";s:3:"end";}}s:11:"media$title";s:37:"Something to Contribute this Passover";s:14:"yt$aspectRatio";s:10:"widescreen";s:11:"yt$duration";a:1:{s:7:"seconds";s:2:"74";}s:11:"yt$uploaded";s:24:"2012-03-26T18:55:42.000Z";s:13:"yt$uploaderId";s:22:"oYqzUf3k0FaTRznc8RZD1g";s:10:"yt$videoid";s:11:"TO0bIwwLVYI";}s:13:"yt$statistics";a:2:{s:13:"favoriteCount";s:1:"0";s:9:"viewCount";s:2:"10";}s:5:"terms";a:3:{i:0;s:9:"Nonprofit";i:1;s:8:"Passover";i:2;s:4:"2012";}s:7:"handler";s:7:"youtube";} [embed_code] => [description] => ) ) ) [rdf_mapping] => Array ( [rdftype] => Array ( [0] => sioc:Item [1] => foaf:Document ) [title] => Array ( [predicates] => Array ( [0] => dc:title ) ) [created] => Array ( [predicates] => Array ( [0] => dc:date [1] => dc:created ) [datatype] => xsd:dateTime [callback] => date_iso8601 ) [changed] => Array ( [predicates] => Array ( [0] => dc:modified ) [datatype] => xsd:dateTime [callback] => date_iso8601 ) [body] => Array ( [predicates] => Array ( [0] => content:encoded ) ) [uid] => Array ( [predicates] => Array ( [0] => sioc:has_creator ) [type] => rel ) [name] => Array ( [predicates] => Array ( [0] => foaf:name ) ) [comment_count] => Array ( [predicates] => Array ( [0] => sioc:num_replies ) [datatype] => xsd:integer ) [last_activity] => Array ( [predicates] => Array ( [0] => sioc:last_activity_date ) [datatype] => xsd:dateTime [callback] => date_iso8601 ) ) [cid] => 0 [last_comment_timestamp] => 1341715638 [last_comment_name] => [last_comment_uid] => 1 [comment_count] => 0 [name] => admin [picture] => 0 [data] => a:1:{s:7:"overlay";i:1;} ) )
ASKER CERTIFIED SOLUTION
Avatar of Easyrider43
Easyrider43Flag of United States of America image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 12 Comments.
See Answers