title: php json - Get Only first element from Array
body: <p>I'm writing code to show data from themoviedb.org API, but still failed to get correct results. I dont know what're wrongs to my PHP codes, but <strong>below code just give me one result from array</strong>, it should be 3 items. <strong>Below code are for testing only</strong> :</p>
  
  <pre><code>&lt;?php
      ...
      $data = json_decode($result, true);
      $data_movie = array($data['results']);   
      $i = 0;     
      foreach ($data_movie as $key =&gt; $val)
      {
         echo $val[$i]['poster_path']."&lt;br/&gt;";
         $i++;
      }           
  ?&gt;
  </code></pre>
  
  <p>But if i do <code>print_r($data_movie)</code>, the data are available...</p>
  
  <p>The <strong>Json</strong> structure:</p>
  
  <pre><code>{
      "page": 1,
      "results": [
          {
              "poster_path": "/6bCplVkhowCjTHXWv49UjRPn0eK.jpg",
              "adult": false,
              "overview": "Fearing the actions of a god-like Super Hero left unchecked, Gotham City’s own formidable, forceful vigilante takes on Metropolis’s most revered, modern-day savior, while the world wrestles with what sort of hero it really needs. And with Batman and Superman at war with one another, a new threat quickly arises, putting mankind in greater danger than it’s ever known before.",
              "release_date": "2016-03-23",
              "genre_ids": [
                  28,
                  12,
                  14,
                  878
              ],
              "id": 209112,
              "original_title": "Batman v Superman: Dawn of Justice",
              "original_language": "en",
              "title": "Batman v Superman: Dawn of Justice",
              "backdrop_path": "/15PbZtjRJ4zgQA8XS0otL70piQi.jpg",
              "popularity": 7.969661,
              "vote_count": 42,
              "video": false,
              "vote_average": 5.68
          },
          {
              "poster_path": "/tSFBh9Ayn5uiwbUK9HvD2lrRgaQ.jpg",
              "adult": false,
              "overview": "Beatrice Prior and Tobias Eaton venture into the world outside of the fence and are taken into protective custody by a mysterious agency known as the Bureau of Genetic Welfare.",
              "release_date": "2016-03-09",
              "genre_ids": [
                  12,
                  878
              ],
              "id": 262504,
              "original_title": "The Divergent Series: Allegiant",
              "original_language": "en",
              "title": "The Divergent Series: Allegiant",
              "backdrop_path": "/jaoDlr7XGGtHs1VpN9macrbXheO.jpg",
              "popularity": 4.624446,
              "vote_count": 42,
              "video": false,
              "vote_average": 6.81
          },
          {
              "poster_path": "/d936U33f5n6bRtzDHh1gmDdriKr.jpg",
              "adult": false,
              "overview": "Waking up from a car accident, a young woman finds herself in the basement of a man who says he's saved her life from a chemical attack that has left the outside uninhabitable.",
              "release_date": "2016-03-09",
              "genre_ids": [
                  18,
                  9648,
                  878,
                  53
              ],
              "id": 333371,
              "original_title": "10 Cloverfield Lane",
              "original_language": "en",
              "title": "10 Cloverfield Lane",
              "backdrop_path": "/u7GyYxTNx8LDYpma605YZvjdOVp.jpg",
              "popularity": 2.90869,
              "vote_count": 10,
              "video": false,
              "vote_average": 2.95
          }
      ],
      "dates": {
          "maximum": "2016-03-27",
          "minimum": "2016-03-06"
      },
      "total_pages": 5,
      "total_results": 97
  }
  </code></pre>