s-c-0-r-p-i-a-n
BANNED
- Nov 20, 2010
- 37
- 2
Code:
<?php
function isBadWord($text)
{
//First we list the bad words in array
$badwords = array(
'truck',
'hi',
'lie',
'bad',
'night',
'eg'
);
//Then we perform the bad word check
foreach($badwords as $badwords)
{
if(stristr($text,$badwords))
{
return true;
}
}
return false;
}
?>
First we need to list the bad words in an array. Then we perform the check using the stristr function which searches for the bad words inside the given text.
If no bad word is found it returns FALSE.
Here is an example of how to use this function
Code:
<?php
$text = '';� //Put your text here to check
if(isBadWord($text))
{
echo 'Bad Word Found!';
}
else
{
echo 'No Bad Word!';
}
?>