/* $adusers is an array of about 7000 elements, each of these elements contain an array which has 1-5 elements in it. $list is an array of about 2000 elements */ function orphans($adusers, $list) { for ($x = 0; $x < sizeof($adusers); $x++) { if (isset($tmpbuffer)) { $tmpbuffer = array_merge($tmpbuffer, $adusers[$x]->emails); } else { $tmpbuffer = $adusers[$x]->emails; } } for ($x = 0; $x < sizeof($list); $x++) { if (!in_array(strtolower($list[$x]), $tmpbuffer)) { $buffer[] = $list[$x]; } } return $buffer; }