PHP Variable Empty Outside Foreach?
<p>I have a class system and a function inside it that does a foreach from DB results. The variable is assigned inside the foreach, but outside of the foreach it is empty.</p>

<pre><code>// Top of file
private $movieList = array();

if ($query-&gt;num_rows() &gt; 0) {
            foreach ($query-&gt;result() as $row) {
                // add each to the array
                $this-&gt;movieList[] = array('nid' =&gt; $row-&gt;nid, 'title' =&gt; $row-&gt;title, 'movie_pos_id' =&gt; $row-&gt;movie_pos_id);
                print_r($this-&gt;movieList); // variable full of stuff
            }
            // No results found
            return false;
        }

print_r($this-&gt;movieList); // variable empty
</code></pre>

<p>Any idea why?</p>
