- array_map: documentation ( source)
- explode: documentation ( source)
- mb_stripos: documentation ( source)
<?php
$keyword_array = array_map('trim',explode(',', "москва, питер, саратов"));
$text = "здравствуй, москва и питер!";
foreach ($keyword_array as $key) {
if (mb_stripos($text, $key) !== false) {
echo "Нашел ".$key.PHP_EOL;
}
}