array_unique causing undefined offset error
<p>I have been trying to use array_unique to remove duplicates from the search results I am populating. However, I am getting an undefined offset error. I was wondering if anyone knows what is causing this error and what I can do to fix it? As you can see below I am populating search results from two different places and trying to merge all matches into one array.</p>

<p>Before array_unique:
Array ( [0] => Bob Marley Footwear [1] => Bob Marley Footwear [2] => DVS Shoe Co. )</p>

<p>After array_unique:
Array ( [0] => Bob Marley Footwear [2] => DVS Shoe Co.)</p>

<p><strong>Note:</strong> this causes an error message to appear when trying to access array slot 1 when iterating through array, to print out the results.</p>

<pre><code>    $results = mysql_query("SELECT keywords,name FROM files WHERE MATCH (keywords,name) AGAINST ('$searchfor')") or die(mysql_error());


    $matches=Array();
    $matches_final=Array();

    while($row = mysql_fetch_array($results)){
        $matches[] = $row['name'];
    }
    $matches_final = array_unique($matches);

    $results1 = mysql_query("SELECT name FROM files");
    while($row1 = mysql_fetch_array($results1)){
        $temp = explode(" ", $row1['name']);

        for($z=0; $z &lt; sizeof($search_words); $z++){
            for($i=0; $i &lt; sizeof($temp); $i++){
                if(((strcmp(strtolower($search_words[$z]), strtolower($temp[$i])))==0) and strlen($search_words[$z])&lt;=5){
                    $matches_final[] = $row1['name'];
                }
            }
        }
    }


return $matches_final;
</code></pre>
