title: foreach only bringing back last item in array
body: <p>I am trying to extract data from an API based on information from two different tables, before cycling through a foreach and parsing this data into the query. I have constructed a series of queries which get me the exact data I'm looking for (name and poster of the first film in an array), however when parsing this data into the foreach which returns a list of a series of films, the variables I have predefined are only being brought back for the final list in the array, rather than cycling through them all, as expected.</p>
  
  <p>Here's what I've got so far:</p>
  
  <p><strong>Processing:</strong></p>
  
  <pre><code>// Get a user's Watchlists from the watchlists table
      $query = "SELECT * FROM watchlists WHERE user_id = " . $profile_info['id']; 
      $watchlist_result = mysql_query($query);
      $watchlists = array();
      while(($row = mysql_fetch_assoc($watchlist_result))) {
          $watchlists[] = $row;
      }
  
      // Count how many Watchlists a user has
      $watchlist_count = count($watchlists);
  
      // Echo details of each Watchlist
      echo "&lt;pre&gt;";
      print_r($watchlists);
      echo "&lt;/pre&gt;";
  
      // For each Watchlist, select all of the films it contains and echo them out
      foreach ($watchlists as $key =&gt; $films) {
          // Get each Watchlist's ID from the watchlists table
          $watchlist_id = $films['watchlist_id'];
          echo "&lt;pre&gt;";
          print_r($watchlist_id);
          echo "&lt;/pre&gt;";
  
          // Extract films from the watchlist_films table for each Watchlist, based on its unique ID and put them into an array
          $watchlist_film_query = "SELECT * FROM watchlist_films WHERE watchlist_id = " . $watchlist_id;
          $watchlist_film_result = mysql_query($watchlist_film_query);
          $watchlist_films = array();
          while(($row = mysql_fetch_assoc($watchlist_film_result))) {
              $watchlist_films[] = $row;
          }
  
          // Echo the new array
          echo "&lt;pre&gt;";
          print_r($watchlist_films);
          echo "&lt;/pre&gt;";
  
          // Get the ID of the first film in each Watchlist
          $rt_id = $watchlist_films[0]['film_id'];
  
          // Echo the ID
          echo "&lt;pre&gt;";
          print_r($rt_id);
          echo "&lt;/pre&gt;";
  
          // Initialise Rotten Tomates API
          include_once('/api/RottenTomatoes.php');
  
          /* Rotten Tomatoes */
          $rottenTomatoes = new RottenTomatoes('2b2cqfxyazbbmj55bq4uhebs', 10, 'uk');
  
          // Search Rotten Tomatoes for details on the first film in the array
          $rottenTomatoes-&gt;movieSearch($rt_id);
  
          //echo "&lt;pre&gt;";
          try {
              $result = $rottenTomatoes-&gt;getMovieInfo($rt_id);
              //print_r($result);
          } catch (Exception $e) {
              //print_r($e);
          }
          //echo "&lt;/pre&gt;";
  
          // Get poster and name of first movie in array
          $thumbnail = $result['posters']['thumbnail'];
          $first_film_name = $result['title'];
  
          echo "&lt;pre&gt;";
          print_r($thumbnail);
          echo "&lt;/pre&gt;";
  
          echo "&lt;pre&gt;";
          print_r($first_film_name);
          echo "&lt;/pre&gt;";
      }
  </code></pre>
  
  <p>Now, I want to parse this information into an actual page and print out all the information for each Watchlist a user has.</p>
  
  <p><strong>Output:</strong></p>
  
  <pre><code>if ($watchlist_count != 0) {?&gt;
                          &lt;ul class="unstyled"&gt;&lt;?php
                              foreach($watchlists as $key =&gt; $watchlist_item) {?&gt;
                                  &lt;li class="well list-item clearfix"&gt;&lt;?php
  
                                      echo "&lt;pre&gt;";
                                      print_r($watchlist_item);
                                      echo "&lt;/pre&gt;";
  
                                      echo "&lt;pre&gt;";
                                      print_r($watchlist_films);
                                      echo "&lt;/pre&gt;";
  
                                      echo "&lt;pre&gt;";
                                      print_r($watchlist_id);
                                      echo "&lt;/pre&gt;";
  
                                      echo "&lt;pre&gt;";
                                      print_r($thumbnail);
                                      echo "&lt;/pre&gt;";
  
                                      echo "&lt;pre&gt;";
                                      print_r($first_film_name);
                                      echo "&lt;/pre&gt;";?&gt;
  
                                      &lt;div class="row-fluid"&gt;
                                          &lt;a href="watchlist.php?id=&lt;?php echo $watchlist_item['watchlist_id']; ?&gt;" title="&lt;?php echo $watchlist_item['name']; ?&gt; Watchlist"&gt;
                                              &lt;img src="&lt;?php echo $thumbnail; ?&gt;" class="span1 pull-left" alt="&lt;?php echo $first_film_name; ?&gt; poster" title="&lt;?php echo $first_film_name; ?&gt; poster" /&gt;
                                          &lt;/a&gt;
  
                                          &lt;div class="span11 movie-info"&gt;
                                              &lt;p class="search-title"&gt;&lt;a href="watchlist.php?id=&lt;?php echo $watchlist_item['watchlist_id']; ?&gt;" title="&lt;?php echo $watchlist_item['name']; ?&gt; Watchlist"&gt;&lt;?php echo $watchlist_item['name']; ?&gt;&lt;/a&gt;&lt;/p&gt;
  
                                              &lt;p class="search-synopsis"&gt;&lt;?php echo $watchlist_item['description']; ?&gt;&lt;/p&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
  
                                  &lt;/li&gt;&lt;?php
                              }?&gt;
                          &lt;/ul&gt;&lt;?php
                      } else {?&gt;
                          &lt;div class="well list-item"&gt;
                              You haven't created any Watchlists yet! Why not visit a movie page now and build your first?
                          &lt;/div&gt;&lt;?php
                      }?&gt;
  </code></pre>
  
  <p>The issue I'm having is that, while the processing section gets me exactly what I want (i.e. the name and thumbnail of the first film in each Watchlist), when I parse this information into the output, <strong>only the name and poster for the first film in the last Watchlist is shown</strong>, as below:</p>
  
  <p><img src="https://i.stack.imgur.com/x1qsA.png" alt="Result"></p>