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.

3 comments:

  1. Thanks for sharing such a nice information with us on PHP and related topics. Very useful lines and to the point. I appreciate your effort , keep sharing such wonderfull things.
    OOPS Interview Questions Answers
    PHP-MySQL Interview Questions Answers
    80 PHP functions asked in Interview

    ReplyDelete
  2. Hey Nice Blog!! Thanks For Sharing!!!Wonderful blog & good post.Its really helpful for me, waiting for a more new post. Keep Blogging!
    best java training in coimbatore
    php training in coimbatore
    best php training institutes in coimbatore

    ReplyDelete

Post Top Ad