$MatchCount = 0; for ($z=0;$z<=$arrLenA;$z++){ for ($i=0;$i<=$arrLenB;$i++){ if ($sentencesA[$z] eq $setencesB{$i}){ $MatchCount++; } } } print $MatchCount;