The following script will replace all bad keywords with *** . The keyword variable accepts multiple keywords, they must be separated with a comma (,) .
$bad_keywords="serial,hack,crack";
if($bad_keywords!="")
{
$bad_keywords=str_replace(",",")|(",$bad_keywords);
$bad_keywords="/($bad_keywords)/i";
$filepath=preg_replace($bad_keywords, "****", $filepath);
}