Untitled
By: a guest | Mar 22nd, 2010 | Syntax:
None | Size: 0.75 KB | Hits: 93 | Expires: Never
function WordFilter($string = "")
{
// Run a mysql query to grab our words
$filter_query_string = "SELECT * FROM forumfilter_fil";
$filter_query = mysql_query($filter_query_string, Core::$dbConn);
// Loop the query and run replacements on the main string
while ($row = mysql_fetch_assoc($filter_query))
{
preg_match("/".$row['word_fil']."/i", $string, $matches);
if (isset($matches['0']))
{
// Get string length
$word_length = strlen($matches['0']);
$stars = "";
// Loop for *'s
for($i = 0; $i < $word_length; $i++)
{
$stars .= "*";
}
$string = preg_replace("/".$row['word_fil']."/i", $stars, $string);
}
}
// Return our new string
return $string;
}