Hello I made a swear filter and it currently searches and replaces for swear words.. Will also replace swear words that look like "s h i t" with spaces in between.
But I have a problem, because of the spaces its stopping as soon (as s).. Now I need to make it so that it doesnt replace the second word if there is still words after it (oon).
Heres my code.
function swear_filter($text)
{
global $db,$replace_filter_arr,$swear_filter_arr,$reloaded_filter_check;
if(!$reloaded_filter_check)
{
$q = $db->Query('SELECT filter FROM funds');
$r = $db->Fetch($q);
$swear_filter_arr = explode("\r", $r['filter']);
$num = 0;
$replace_filter_arr = array();
$f_words = '!%$#$#!$%@#!$';
foreach($swear_filter_arr as $line)
{
$amt_of = strlen($line);
if($num > 0) { $line = substr($line, 1); }
$in_line = array();
$in_line = preg_split("//", $line);
unset($line);
$new_num = 0;
foreach($in_line as $new_line)
{
if($new_num > 0) { $line .= "$new_line( )*(-_\*\+)*"; }
$new_num++;
}
$swear_filter_arr[$num] = "/$line/i";
$replace_filter_arr[$num] = substr($f_words, 0, $amt_of);
$num++;
}
$reloaded_filter_check++;
}
return(preg_replace($swear_filter_arr, $replace_filter_arr, $text));
}