Results 1 to 2 of 2

Thread: Finding matches in two arrays

  1. #1

    Finding matches in two arrays

    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 Code:
    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
    "You are playing a very dangerous game"
    "Change always is"

    Creativo Development

  2. #2
    Check out the array_diff and array_intersect function families.
    Wait, what?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012