Usa array_map() per filtrare e normalizzare entrambi gli array (es. con trim() e strtolower()).
Poi usa array_intersect() per trovare tutte le parole che sono presenti in entrambi gli array.
https://www.php.net/array_map
https://www.php.net/trim
https://www.php.net/strtolower
https://www.php.net/array_intersect