$a=["a","b","c","d","e"]; $b=["d","e","f","g"]; $inBothAndB = array_intersect($a, $b); // Array([3] => d [4] => e)