Web Development and Design | Tutorial for Java, PHP, HTML, Javascript: filter

Web Development and Design | Tutorial for Java, PHP, HTML, Javascript: filter
Showing posts with label filter. Show all posts
Showing posts with label filter. Show all posts

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.
2