PHP Function To Check If String Contain Bad Words or Not


PHP Function To Check If String Contain Bad Words or Not

PHP Filter String


Here is a function Created For You To Check if string Contains Bad Word,Abusive Word or Not.

Code:-
<?php
function badword($text){
$bad = array('bad','lips','somebadword');
$rep = array('***','***','***','***');
//You Can More Bad Words in Array According To What You want filter
$text2 = str_replace($bad, $rep, $text);


if ($text != $text2)
{
return "bad";
}
else
{
return "good";
}
}

$text = "hello bad";
echo badword($text);
//Return Good Or Bad According To Text.
?>
Thanks.
Previous Post
Next Post

post written by:

2 comments: