$original_keywords = "cat, dog, mouse";
$possible_keywords_1 = "cat, dog, hamster";
$possible_keywords_2 = "cat, sheep, goat";
// Put the input keywords into an array
$keywords = explode(', ', $original_keywords);
// Put all incoming keywords into one big array (you can add as many arrays
// as you want here)
$input = array_merge(
explode(', ', $possible_keywords_1),
explode(', ', $possible_keywords_2));
// Count how many times each keywords from $input appears
$count = array_count_values($input);
// Filter out from $count any keyword that is not present in $keywords
$result = array_intersect_key($count, array_flip($keywords));
Посмотреть в действии .