PHP- Create an array with the matches of two arrays
<p>I am trying to compare two non-associative arrays to create a new array with the matches.</p>

<p>This is what I have though:</p>

<pre><code>//This array has several entries
$a_firstarray = Array();
//This array has less entries than the first array
$a_secondarray = Array();
//This array should contain the matches of the first array and the second array in no particular order
$a_mergedarray

    for($i=0;$i &lt;=count($a_firstarray);$i++){
            for($a=0;$a &lt;=count ($a_secondarray);$a++){
                if($a_firstarray[$i] == $a_secondarray[$a]){
                    $a_mergedarray[] = $a_activecategory[$i];
                }
            }
        }
</code></pre>

<p>It doesn't work for some reason. I am also sure that PHP has some sort of function that does this. Any ideas? thanks in advance.</p>