PHP Function To Check If String Contain Bad Words or Not - Web Development and Design | Tutorial for Java, PHP, HTML, Javascript PHP Function To Check If String Contain Bad Words or Not - Web Development and Design | Tutorial for Java, PHP, HTML, Javascript

Breaking

Post Top Ad

Post Top Ad

Sunday, May 28, 2017

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.

No comments:

Post a Comment

Post Top Ad