PHP: Why does my variable error when passed as reference as undefined now?
<p>I have a function that i pass a variable as reference into that an array gets stored into. Before, it also took a second reference variable to store an image url. When it used both of these everything worked fine and i did not get an undefined variable error. Now i have removed the image part and included it into the array that is stored in the single reference variable and it tells me that the variable i am passing is undefined.</p>

<p>Here is my function:</p>

<pre><code>&lt;?php
function retrieve_t($movie_title, &amp;$movie_data) {
    $url = "http://www.imdbapi.com/?t=".urlencode($movie_title);
    $content = file_get_contents($url);
    if(substr($content, 2, 8) == "Response")
        return false;
    $data_array = explode("\",\"", substr($content,2,strlen($content)-4));
    $data_array2 = array();
    foreach ($data_array as $value) {
        $temp = explode("\":\"", $value);
        array_push($data_array2, $temp[0]);
        array_push($data_array2, $temp[1]);
    }
    $movie_data = array($data_array2[0] =&gt; $data_array2[1],
                            $data_array2[2] =&gt; $data_array2[3],
                            $data_array2[4] =&gt; $data_array2[5], 
                            $data_array2[8] =&gt; $data_array2[9], 
                            $data_array2[10] =&gt; $data_array2[11],
                            $data_array2[12] =&gt; $data_array2[13],
                            $data_array2[14] =&gt; $data_array2[15],
                            $data_array2[16] =&gt; $data_array2[17],
                            $data_array2[18] =&gt; $data_array2[19],
                            $data_array2[22] =&gt; $data_array2[23],
                            "img_url" =&gt; $data_array2[21]);
    return true;
}
 ?&gt;
</code></pre>

<p>And here is where it is called:</p>

<pre><code>&lt;?php include "imdb_search.php"; ?&gt;
&lt;?php 
if(isset($_GET["add"]) &amp;&amp; $_GET["title"])
    if($_GET["add"] == "yes") {
        include "db_movie_add.php"; 
        $title = $_GET["title"];
        if(retrieve_t($title, $movie_data))
            add_movie($movie_data);
    }
 ?&gt;
 &lt;html&gt;
&lt;head&gt;
    &lt;title&gt;First Page&lt;/title&gt;
&lt;/head&gt;
&lt;Body&gt;
    &lt;form&gt;
        Title: &lt;input value="&lt;?php if (isset($_GET["title"])) echo $_GET["title"]; ?&gt;" type="text" name="title" /&gt;&lt;br /&gt;
        &lt;input type="submit" value="Search" /&gt;
    &lt;/form&gt;
    &lt;?php
        if(isset($_GET["title"])) {
            $title = $_GET["title"];
            if(retrieve_t($title, $movie_data)) {
                echo "&lt;img src=\"{$movie_data["img_url"]}\" width=\"200\"&gt;&lt;br \&gt;";
                echo "Title: {$movie_data["Title"]}&lt;br \&gt;";
                echo "&lt;form&gt;&lt;input type=\"hidden\" name=\"title\" value=\"{$title}\"&gt;&lt;input type=\"hidden\" name=\"add\" value=\"yes\"&gt;&lt;input type=\"submit\" value=\"Add\" /&gt;&lt;/form&gt;";
            } else {
                echo "Sorry, movie was not found!";
            }
        }
    ?&gt;
&lt;/Body&gt;
&lt;/html&gt;
</code></pre>
