php bad word filter
![]() |
php bad word filter--Get rid of Hateful Words |
you can stop user to use bad words..you also ban user to advertise their website domain...
php example : php word filter:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | <font color= "green" ><b>PHP Words Filter</b></font> <form method= "post" > <font color= "orange" ><b><i>Your Content:</i></b></font> <textarea name= "name" rows= "8" cols= "30" placeholder= "Ex: fear,anger,love,good,bad,name,you,your..." /></textarea> <input type= "submit" name= "submit" value= "Check" /> </form> <?php //Lists Of Filtered Words here $words = array ( 'FEAR' , 'ANGER' , 'LOVE' , 'GOOD' , 'BAD' , 'NAME' , 'YOU' , 'YOUR' , 'DOG' , 'CAT' , 'HELLO' , 'GO' , 'OUT' ); if (isset( $_POST [ 'submit' ])){ if (! empty ( $_POST [ 'name' ])){ $total = str_word_count ( $_POST [ 'name' ]); $inputname = strtoupper ( $_POST [ 'name' ]); $name = explode ( ' ' , $inputname ); if ( array_intersect ( $words , $name )){ $wordarray = array_intersect ( $words , $name ); foreach ( $wordarray as $row ){ echo '<font color=red><b>(' . $row . ')</b></font> | ' ; } if ( count ( $wordarray )==1){ echo 'is Restricted Word' ; } else { echo 'are Restricted Words' ; } } else { echo '<font color=green><b>Thank Your Article Does not Contain Harmful Words</b></font> ' ; } } } ?> |
That's It...
1 | $words = array ( 'FEAR' , 'ANGER' , 'LOVE' , 'GOOD' , 'BAD' , 'NAME' , 'YOU' , 'YOUR' , 'DOG' , 'CAT' , 'HELLO' , 'GO' , 'OUT' ); |
put Your Restricted words in array..note: words must be uppercase..
That's it Friends How to bad word filter using php..Keep visiting ..Thank You..
No comments:
Post a Comment
Thank You for Your Comment
Note: Only a member of this blog may post a comment.