重複の可能性:
単語に特定の文字列が含まれている場合は、単語全体を削除します
単語を含む単語全体を削除するにはどうすればよいですか?たとえば、「リリース」はリリース済み、リリースリリースなどを削除する必要があります。
/* Read in from the file here, not in the function - you only need to read the file once */
$wordlist = array('release','announce');
/* Sample data */
$words = 'adobe releases releases Acrobat X';
foreach ($wordlist as $v)
$words = clean($v,$words);
function clean($wordlist,$value)
{
return preg_replace("/\b$wordlist\b/i", '***',trim($value));
}
echo 'Words: '.$words.PHP_EOL;