Forum Moderators: coopster
function language_filter($string) {
$obscenities = array(" expletive1 ", " expletive1", " expletive2 ", " expletive2");
foreach ($obscenities as $banned) {
if (stristr(trim($string), $banned)) {
$length = strlen($banned);
for ($i = 1; $i <= $length; $i++) {
$asterisk .= "*";
}
$string = eregi_replace($banned, $asterisk, trim($string));
$asterisk = "";
}
}
return $string;
}$the_article = language_filter($the_article);
This works, but when a banned string is contained within a longer word, the asterisks are substituted, which I don't want.
Is there a way that I can specify that a banned string should only be subsituted when it appears standalone or at the beginning of a word? At present I've done this by putting a space at both ends of it and repeating it with a space only at the start, but that doesn't seem too elegant.
Regards,
Patrick
[mkssoftware.com...]