title: how to decode youtube api v3 json response
body: <p>here is my youtube json response </p>
  
  <pre><code>    query results:Array
  (
      [kind] =&gt; youtube#searchListResponse
      [etag] =&gt; "tbWC5XrSXxe1WOAx6MK9z4hHSU8/_RyGfO1dwDRqY9aMf412I8xvZgw"
      [nextPageToken] =&gt; CAoQAA
      [pageInfo] =&gt; Array
          (
              [totalResults] =&gt; 1000000
              [resultsPerPage] =&gt; 10
          )
  
      [items] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [kind] =&gt; youtube#searchResult
                      [etag] =&gt; "tbWC5XrSXxe1WOAx6MK9z4hHSU8/vJBGevzCpIbHOcHu7AAc4WsQ92E"
                      [id] =&gt; Array
                          (
                              [kind] =&gt; youtube#video
                              [videoId] =&gt; eHfMfHyiWYA
                          )
  
                      [snippet] =&gt; Array
                          (
                              [publishedAt] =&gt; 2013-11-04T16:09:20.000Z
                              [channelId] =&gt; UCSvOdBJgMnTYsK-cZIGZSYQ
                              [title] =&gt; Ann Arbor - a test bed for driverless cars?
                              [description] =&gt; University of Michigan researchers work to make Ann Arbor the first American city with a shared fleet of connected and driverless vehicles by 2021. The cars of ...
                              [thumbnails] =&gt; Array
                                  (
                                      [default] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/eHfMfHyiWYA/default.jpg
                                          )
  
                                      [medium] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/eHfMfHyiWYA/mqdefault.jpg
                                          )
  
                                      [high] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/eHfMfHyiWYA/hqdefault.jpg
                                          )
  
                                  )
  
                              [channelTitle] =&gt; michiganengineering
                              [liveBroadcastContent] =&gt; none
                          )
  
                  )
  
              [1] =&gt; Array
                  (
                      [kind] =&gt; youtube#searchResult
                      [etag] =&gt; "tbWC5XrSXxe1WOAx6MK9z4hHSU8/9Mm7w3esGwaHCTasG_67T33aULE"
                      [id] =&gt; Array
                          (
                              [kind] =&gt; youtube#video
                              [videoId] =&gt; PRvGaCnfV-8
                          )
  
                      [snippet] =&gt; Array
                          (
                              [publishedAt] =&gt; 2009-01-26T16:50:35.000Z
                              [channelId] =&gt; UCPkN7EcOJlQAzCLxaZSn_5g
                              [title] =&gt; Timelapse Cars
                              [description] =&gt; 
                              [thumbnails] =&gt; Array
                                  (
                                      [default] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/PRvGaCnfV-8/default.jpg
                                          )
  
                                      [medium] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/PRvGaCnfV-8/mqdefault.jpg
                                          )
  
                                      [high] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/PRvGaCnfV-8/hqdefault.jpg
                                          )
  
                                  )
  
                              [channelTitle] =&gt; frehleycomet
                              [liveBroadcastContent] =&gt; none
                          )
  
                  )
  
              [2] =&gt; Array
                  (
                      [kind] =&gt; youtube#searchResult
                      [etag] =&gt; "tbWC5XrSXxe1WOAx6MK9z4hHSU8/9_WnlpVsvx2WLKqdgxGXI3CRvBE"
                      [id] =&gt; Array
                          (
                              [kind] =&gt; youtube#video
                              [videoId] =&gt; U60TfgpHqSc
                          )
  
                      [snippet] =&gt; Array
                          (
                              [publishedAt] =&gt; 2013-07-01T23:23:59.000Z
                              [channelId] =&gt; UCULJH9kW-UdTBCDu27P0BoA
                              [title] =&gt; Are cars killing the Bicycle Kingdom?
                              [description] =&gt; Bike advocacy in the Bicycle Kingdom? China was once known as the Bicycle Kingdom but with the growth of the automobile, the nature of biking in Beijing is ...
                              [thumbnails] =&gt; Array
                                  (
                                      [default] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/U60TfgpHqSc/default.jpg
                                          )
  
                                      [medium] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/U60TfgpHqSc/mqdefault.jpg
                                          )
  
                                      [high] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/U60TfgpHqSc/hqdefault.jpg
                                          )
  
                                  )
  
                              [channelTitle] =&gt; llukitsch
                              [liveBroadcastContent] =&gt; none
                          )
  
                  )
  
              [3] =&gt; Array
                  (
                      [kind] =&gt; youtube#searchResult
                      [etag] =&gt; "tbWC5XrSXxe1WOAx6MK9z4hHSU8/_2N5Lkva8p_pbJqLf5K61gNPHL0"
                      [id] =&gt; Array
                          (
                              [kind] =&gt; youtube#video
                              [videoId] =&gt; Xg5-oxTSM04
                          )
  
                      [snippet] =&gt; Array
                          (
                              [publishedAt] =&gt; 2014-02-13T17:42:31.000Z
                              [channelId] =&gt; UC-Gu_VkJmS1FGxsrSddKvfg
                              [title] =&gt; Market America's 2014 World Conference: FreeBee Cars
                              [description] =&gt; Market America's 2014 World Conference in Miami featured FreeBee cars showcasing MA brands like Motives® Cosmetics and DNA Miracles™.
                              [thumbnails] =&gt; Array
                                  (
                                      [default] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/Xg5-oxTSM04/default.jpg
                                          )
  
                                      [medium] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/Xg5-oxTSM04/mqdefault.jpg
                                          )
  
                                      [high] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/Xg5-oxTSM04/hqdefault.jpg
                                          )
  
                                  )
  
                              [channelTitle] =&gt; MarketAmerica
                              [liveBroadcastContent] =&gt; none
                          )
  
                  )
  
              [4] =&gt; Array
                  (
                      [kind] =&gt; youtube#searchResult
                      [etag] =&gt; "tbWC5XrSXxe1WOAx6MK9z4hHSU8/VXZohXlA5kHPvrJ-rxpdEjUsaFY"
                      [id] =&gt; Array
                          (
                              [kind] =&gt; youtube#video
                              [videoId] =&gt; yrcq5awviik
                          )
  
                      [snippet] =&gt; Array
                          (
                              [publishedAt] =&gt; 2011-06-01T23:31:01.000Z
                              [channelId] =&gt; UC1URrXTrZ68pZZ4YDmT4WVQ
                              [title] =&gt; Ford's connected cars get street-smart
                              [description] =&gt; At AT&amp;T Park in San Francisco, SmartPlanet correspondent Sumi Das talks to Ford's Mike Shulman about the company's research into intelligent vehicles.
                              [thumbnails] =&gt; Array
                                  (
                                      [default] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/yrcq5awviik/default.jpg
                                          )
  
                                      [medium] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/yrcq5awviik/mqdefault.jpg
                                          )
  
                                      [high] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/yrcq5awviik/hqdefault.jpg
                                          )
  
                                  )
  
                              [channelTitle] =&gt; SmartPlanetCBS
                              [liveBroadcastContent] =&gt; none
                          )
  
                  )
  
              [5] =&gt; Array
                  (
                      [kind] =&gt; youtube#searchResult
                      [etag] =&gt; "tbWC5XrSXxe1WOAx6MK9z4hHSU8/FWmwcjir_8QSK6eq5D5gsY-lWXQ"
                      [id] =&gt; Array
                          (
                              [kind] =&gt; youtube#video
                              [videoId] =&gt; bFV7WU6UHaQ
                          )
  
                      [snippet] =&gt; Array
                          (
                              [publishedAt] =&gt; 2014-05-14T10:59:48.000Z
                              [channelId] =&gt; UCI1H2wxkvshpCcUNNOEc4Gw
                              [title] =&gt; Google's Driverless Cars Take to the Streets
                              [description] =&gt; Google's self-driving car technology is not likely to be available for several more years. But the company is already beginning the job of making the public ...
                              [thumbnails] =&gt; Array
                                  (
                                      [default] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/bFV7WU6UHaQ/default.jpg
                                          )
  
                                      [medium] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/bFV7WU6UHaQ/mqdefault.jpg
                                          )
  
                                      [high] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/bFV7WU6UHaQ/hqdefault.jpg
                                          )
  
                                  )
  
                              [channelTitle] =&gt; IBTimesUK
                              [liveBroadcastContent] =&gt; none
                          )
  
                  )
  
              [6] =&gt; Array
                  (
                      [kind] =&gt; youtube#searchResult
                      [etag] =&gt; "tbWC5XrSXxe1WOAx6MK9z4hHSU8/t7dSXvQ-37jK0DFYHxk4iP1o3-s"
                      [id] =&gt; Array
                          (
                              [kind] =&gt; youtube#video
                              [videoId] =&gt; ifzSVGEHxMU
                          )
  
                      [snippet] =&gt; Array
                          (
                              [publishedAt] =&gt; 2012-10-22T13:45:39.000Z
                              [channelId] =&gt; UC6s5vC0tCuStbt4d5dfhmjA
                              [title] =&gt; Project C.A.R.S: BMW Z4
                              [description] =&gt; Scott tries out the newest car to be added, the BMW Z4. Those of you waiting for Tekkit, it will return soon! Hound is currently in the process of moving! Pl...
                              [thumbnails] =&gt; Array
                                  (
                                      [default] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/ifzSVGEHxMU/default.jpg
                                          )
  
                                      [medium] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/ifzSVGEHxMU/mqdefault.jpg
                                          )
  
                                      [high] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/ifzSVGEHxMU/hqdefault.jpg
                                          )
  
                                  )
  
                              [channelTitle] =&gt; scott2k44
                              [liveBroadcastContent] =&gt; none
                          )
  
                  )
  
              [7] =&gt; Array
                  (
                      [kind] =&gt; youtube#searchResult
                      [etag] =&gt; "tbWC5XrSXxe1WOAx6MK9z4hHSU8/RW6QW1hjACRmSo6Za1BzsP1gbSk"
                      [id] =&gt; Array
                          (
                              [kind] =&gt; youtube#video
                              [videoId] =&gt; YZggnfolreA
                          )
  
                      [snippet] =&gt; Array
                          (
                              [publishedAt] =&gt; 2015-05-08T21:32:35.000Z
                              [channelId] =&gt; UC87geOOB2rCWkJFtUUeEBsw
                              [title] =&gt; Project CARS vs. DriveClub | Graphics, Sound, Rain &amp; Weather Effects Gameplay Comparison (PS4)
                              [description] =&gt; Comparing the biggest racing games available on the PS4, DriveClub (PS4 exclusive) and Project CARS (also available on PC and Xbox One). Both games are ...
                              [thumbnails] =&gt; Array
                                  (
                                      [default] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/YZggnfolreA/default.jpg
                                          )
  
                                      [medium] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/YZggnfolreA/mqdefault.jpg
                                          )
  
                                      [high] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/YZggnfolreA/hqdefault.jpg
                                          )
  
                                  )
  
                              [channelTitle] =&gt; VideoGamesNL
                              [liveBroadcastContent] =&gt; none
                          )
  
                  )
  
              [8] =&gt; Array
                  (
                      [kind] =&gt; youtube#searchResult
                      [etag] =&gt; "tbWC5XrSXxe1WOAx6MK9z4hHSU8/OIAM0bSsr9oHqPwPPg3msZUqeMU"
                      [id] =&gt; Array
                          (
                              [kind] =&gt; youtube#video
                              [videoId] =&gt; hJxFid8A0Xw
                          )
  
                      [snippet] =&gt; Array
                          (
                              [publishedAt] =&gt; 2015-04-02T16:00:05.000Z
                              [channelId] =&gt; UCNjakstwb629k6IE9BualRw
                              [title] =&gt; Comedians In Cars Getting Coffee: Single Shot - Analogy Lad
                              [description] =&gt; Watch it on Crackle: [http://bit.ly/SingleShot] Jerry's special guests are Todd Barry, George Wallace, Sarah Silverman, Fred Armisen, Kevin Hart and Jimmy ...
                              [thumbnails] =&gt; Array
                                  (
                                      [default] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/hJxFid8A0Xw/default.jpg
                                          )
  
                                      [medium] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/hJxFid8A0Xw/mqdefault.jpg
                                          )
  
                                      [high] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/hJxFid8A0Xw/hqdefault.jpg
                                          )
  
                                  )
  
                              [channelTitle] =&gt; Crackle
                              [liveBroadcastContent] =&gt; none
                          )
  
                  )
  
              [9] =&gt; Array
                  (
                      [kind] =&gt; youtube#searchResult
                      [etag] =&gt; "tbWC5XrSXxe1WOAx6MK9z4hHSU8/Q945pOROs0oCGIOcFFq66OWZZdw"
                      [id] =&gt; Array
                          (
                              [kind] =&gt; youtube#video
                              [videoId] =&gt; I00AXDv8ncY
                          )
  
                      [snippet] =&gt; Array
                          (
                              [publishedAt] =&gt; 2015-05-07T07:03:27.000Z
                              [channelId] =&gt; UCyQCcFWSh7MLAhdq2a_2jKA
                              [title] =&gt; Project CARS Online #1 - Los gehts! - Formula A @Monza | Wheel/Controller
                              [description] =&gt; Project CARS ist ein Motorsport Multiplayer-Simulation Spiel, entwickelt und veröffentlicht vom britischen Video-Spiel-Entwickler Slightly Mad Studios.
                              [thumbnails] =&gt; Array
                                  (
                                      [default] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/I00AXDv8ncY/default.jpg
                                          )
  
                                      [medium] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/I00AXDv8ncY/mqdefault.jpg
                                          )
  
                                      [high] =&gt; Array
                                          (
                                              [url] =&gt; https://i.ytimg.com/vi/I00AXDv8ncY/hqdefault.jpg
                                          )
  
                                  )
  
                              [channelTitle] =&gt; 
                              [liveBroadcastContent] =&gt; none
                          )
  
                  )
  
          )
  
  )   
  </code></pre>
  
  <p>i want to extract video title, thumbnail, description from this json response using foreach loop</p>
  
  <p>i tried this one but its gives me an error please help me to solve this issues.</p>
  
  <p>my php code is </p>
  
  <pre><code>$link = 'https://www.googleapis.com/youtube/v3/search?order=rating&amp;part=snippet&amp;q=cars&amp;maxResults=10&amp;key={KEY}';
  
  $video = file_get_contents($link);
  $video = json_decode($video, true); 
  echo '&lt;pre&gt;';
  print_r("query results:");
  print_r($video);
  '&lt;/pre&gt;';
  
  foreach ($video-&gt;items as $data ){
      echo "{$data-&gt;snippet-&gt;title}";
      echo "&lt;br&gt;";
  }
  </code></pre>