title: Youtube API PHP json decode
body: <p>I'm trying to search youtube and grab the videos video ID and title.</p>
  
  <p>In the bellow example I am searching for "youtube":   </p>
  
  <pre><code>&lt;?php
      $url="http://gdata.youtube.com/feeds/api/videos?q='youtube'&amp;format=5&amp;max-results=2&amp;v=2&amp;alt=jsonc";
      $json = file_get_contents($url,0,null,null);
      $json_output = json_decode($json);
       echo '&lt;pre&gt;';
        print_r("query results:");
        print_r($json_output);
       '&lt;/pre&gt;';
      foreach ( $json_output-&gt;data as $data ){
      echo "{$data-&gt;id}";
      echo "{$data-&gt;title}";
      }
      ?&gt;
  </code></pre>
  
  <p>Here is the json output for the above query:</p>
  
  <pre><code>query results:stdClass Object
  (
      [apiVersion] =&gt; 2.1
      [data] =&gt; stdClass Object
          (
              [updated] =&gt; 2012-03-04T20:19:06.314Z
              [totalItems] =&gt; 1000000
              [startIndex] =&gt; 1
              [itemsPerPage] =&gt; 2
              [items] =&gt; Array
                  (
                      [0] =&gt; stdClass Object
                          (
                              [id] =&gt; IpSYwvzKukI
                              [uploaded] =&gt; 2009-03-14T08:17:36.000Z
                              [updated] =&gt; 2012-02-29T10:51:35.000Z
                              [uploader] =&gt; kenbedict009
                              [category] =&gt; Music
                              [title] =&gt; one of the funniest kid in youtube!!
                              [description] =&gt; he is a 3 years old korean,this kid makes me laugh
                              [tags] =&gt; Array
                                  (
                                      [0] =&gt; rin on the rox
                                      [1] =&gt; charice pempengco
                                      [2] =&gt; joeydiamond
                                  )
  
                              [thumbnail] =&gt; stdClass Object
                                  (
                                      [sqDefault] =&gt; http://i.ytimg.com/vi/IpSYwvzKukI/default.jpg
                                      [hqDefault] =&gt; http://i.ytimg.com/vi/IpSYwvzKukI/hqdefault.jpg
                                  )
  
                              [player] =&gt; stdClass Object
                                  (
                                      [default] =&gt; http://www.youtube.com/watch?v=IpSYwvzKukI&amp;feature=youtube_gdata_player
                                      [mobile] =&gt; http://m.youtube.com/details?v=IpSYwvzKukI
                                  )
  
                              [content] =&gt; stdClass Object
                                  (
                                      [5] =&gt; http://www.youtube.com/v/IpSYwvzKukI?version=3&amp;f=videos&amp;app=youtube_gdata
                                      [1] =&gt; rtsp://v1.cache6.c.youtube.com/CiILENy73wIaGQlCusr8wpiUIhMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp
                                      [6] =&gt; rtsp://v8.cache2.c.youtube.com/CiILENy73wIaGQlCusr8wpiUIhMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp
                                  )
  
                              [duration] =&gt; 344
                              [rating] =&gt; 4.6304307
                              [likeCount] =&gt; 23419
                              [ratingCount] =&gt; 25803
                              [viewCount] =&gt; 9848083
                              [favoriteCount] =&gt; 15390
                              [commentCount] =&gt; 16074
                              [accessControl] =&gt; stdClass Object
                                  (
                                      [comment] =&gt; allowed
                                      [commentVote] =&gt; allowed
                                      [videoRespond] =&gt; moderated
                                      [rate] =&gt; allowed
                                      [embed] =&gt; allowed
                                      [list] =&gt; allowed
                                      [autoPlay] =&gt; allowed
                                      [syndicate] =&gt; allowed
                                  )
  
                          )
  
                      [1] =&gt; stdClass Object
                          (
                              [id] =&gt; PPNMGYOm1aM
                              [uploaded] =&gt; 2011-06-23T16:35:33.000Z
                              [updated] =&gt; 2012-02-29T13:15:47.000Z
                              [uploader] =&gt; shakeitupvevo
                              [category] =&gt; Music
                              [title] =&gt; "Watch Me" from Disney Channel's "Shake It Up"
                              [description] =&gt; To download Watch Me visit www.smarturl.it Performed by Bella Thorne and Zendaya
                              [tags] =&gt; Array
                                  (
                                      [0] =&gt; Bella
                                      [1] =&gt; Thorne
                                      [2] =&gt; Zendaya
                                      [3] =&gt; Cast
                                      [4] =&gt; of
                                      [5] =&gt; Shake
                                      [6] =&gt; It
                                      [7] =&gt; Up:
                                      [8] =&gt; Break
                                      [9] =&gt; Down
                                      [10] =&gt; Watch
                                      [11] =&gt; Me
                                      [12] =&gt; Walt
                                      [13] =&gt; Disney
                                      [14] =&gt; Soundtrack
                                  )
  
                              [thumbnail] =&gt; stdClass Object
                                  (
                                      [sqDefault] =&gt; http://i.ytimg.com/vi/PPNMGYOm1aM/default.jpg
                                      [hqDefault] =&gt; http://i.ytimg.com/vi/PPNMGYOm1aM/hqdefault.jpg
                                  )
  
                              [player] =&gt; stdClass Object
                                  (
                                      [default] =&gt; http://www.youtube.com/watch?v=PPNMGYOm1aM&amp;feature=youtube_gdata_player
                                  )
  
                              [content] =&gt; stdClass Object
                                  (
                                      [5] =&gt; http://www.youtube.com/v/PPNMGYOm1aM?version=3&amp;f=videos&amp;app=youtube_gdata
                                  )
  
                              [duration] =&gt; 193
                              [aspectRatio] =&gt; widescreen
                              [rating] =&gt; 4.7312055
                              [likeCount] =&gt; 145059
                              [ratingCount] =&gt; 155509
                              [viewCount] =&gt; 48201555
                              [favoriteCount] =&gt; 69981
                              [commentCount] =&gt; 81938
                              [status] =&gt; stdClass Object
                                  (
                                      [value] =&gt; restricted
                                      [reason] =&gt; limitedSyndication
                                  )
  
                              [restrictions] =&gt; Array
                                  (
                                      [0] =&gt; stdClass Object
                                          (
                                              [type] =&gt; country
                                              [relationship] =&gt; deny
                                              [countries] =&gt; DE
                                          )
  
                                  )
  
                              [accessControl] =&gt; stdClass Object
                                  (
                                      [comment] =&gt; allowed
                                      [commentVote] =&gt; allowed
                                      [videoRespond] =&gt; allowed
                                      [rate] =&gt; allowed
                                      [embed] =&gt; allowed
                                      [list] =&gt; allowed
                                      [autoPlay] =&gt; allowed
                                      [syndicate] =&gt; allowed
                                  )
  
                          )
  
                  )
  
          )
  
  )
  </code></pre>
  
  <p>Im trying to echo out [id] and [title]. Any idea what I am doing wrong?</p>
  
  <p>Thanks! </p>