# Finding matches in two arrays

**URL:** <https://forum.kirupa.com/t/finding-matches-in-two-arrays/295924>\
**Category:** programming\
**Created:** [September 7, 2009, 2:31pm UTC](https://forum.kirupa.com/t/finding-matches-in-two-arrays/295924 "2009-09-07T14:31:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![imagined](https://avatars.discourse-cdn.com/v4/letter/i/a87d85/32.png) [@imagined](https://forum.kirupa.com/u/imagined)\
**Post date:** [September 7, 2009, 2:31pm UTC](https://forum.kirupa.com/t/finding-matches-in-two-arrays/295924/1 "2009-09-07T14:31:39Z")

</div>

I have two arrays. I need to find the ones that match and the ones that don’t match.

Array 1 has about 2000 records  
Array 2 has about 7000 records

How could I find the keys of the arrays from Array 1 that match Array 2 and the ones that don’t match?

I tried a combination of things, but they don’t seem to be very accurate and I run into different problems. I was doing something like this

```php

while($row=mysql_fetch_array($result))
{
   $i=0;
   foreach($array2 as $key => $value)
   {
      if($array2['something']==$row['something'])
      {
            // it's a match!
       }
       elseif(count($array2)==$i)
       {
           // not a match
           $i=0;
        }
   $i++;
   }
}

```

Thanks in advance :hr:
