I'm trying to return a single thumbnail from the following array. Right now, foreach loops through the entire array, giving me 4 thumbnails - I only want the first one. The original code: $videoThumbnails = $videoEntry->getVideoThumbnails(); foreach($videoThumbnails as $videoThumbnail) { echo "<img src='".$videoThumbnail['url']."' height='".$videoThumbnail['height']."' width='".$videoThumbnail['width']."' /> \n"; } Code (markup): If I try the following, I get nothing in response. $videoThumbnails = $videoEntry->getVideoThumbnails(); echo "<img src='".$videoThumbnails['url']."' height='".$videoThumbnails['height']."' width='".$videoThumbnails['width']."' /> \n"; Code (markup): Can anyone provide insight? Thank you!
It sounds like its an array of hashes given your use of foreach. So. $videoThumbnails = $videoEntry->getVideoThumbnails(); echo "<img src='".$videoThumbnail[0]['url']."' height='".$videoThumbnail[0]['height']."' width='".$videoThumbnail[0]['width']."' /> \n"; PHP:
Perfect, thanks! I had tried ['url'][0] previously, and that hadn't worked, but didn't try putting the number first. Thanks!