do i need to create another database for this??
because i already have the database of bad words...
if i need to create new....please help how and what will be the value for each field...
<?php
include('../../includes/inc.conn.php');
function swear_filter($string)
{
$words = array();
$query = "SELECT word FROM bad_words";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
$words[] = '/\b' . $row['word'] . '\b/i';
}
return preg_replace($words, '***', $string);
}
$string_to_check = "My shitzu took a Shit on the carpet.";
echo swear_filter($string_to_check);
//Assuming the word 'shit' is in the db results
//Output: "My shitzu took a *** on the carpet"
?>