Code.GeekInterview.com
  I am new, Sign me up!
 
Code Samples PHP
 

Custom Filtering Unwanted Words


Code ResourceAuthor: Lokesh M  

Difficulty Level:

Published: 25th May 2007   Read: 1011 times  

Filed in: PHP
Add Comment


 


The function filterbanwords filters out list of pre-defined words. so as the make the final output clean and tidy. $word holds comma seperated words that needs to be eliminated from the text which is passed as parameter $text to the function.

 


Sample Code
  1.  
  2. function filterbanwords($text)
  3. {
  4.      $word = "gambling, clone, poker, buy, cheap, sell, cam";
  5.      $strs = explode(',', $word);
  6.  
  7.      $allowtxt=1;
  8.      foreach($strs as $key=>$value)
  9.      {
  10.        $value = trim($value);
  11.        $aBadWords = "[ ](".$value.")[,]";
  12.        $aBadWords = "(".$value.")";
  13.  
  14.        if (eregi($aBadWords,$text)) {
  15.        $allowtxt=0; }
  16.      }
  17.      return $allowtxt;
  18. }
  19.  
Copyright GeekInterview.com


Next Article: Customer List With Edit and Delete Options


 

Latest Code Samples

 

Popular Code Samples

 

Related Code Samples

 

Post Comment


Members Please Login

Name:  Email: (Optional. Used for Notification)

Title:
 
Comment:
Validation Code: <=>  (Enter this code in text box)





Popular Coders

# Coder NameHits
1. chowsys7299
2. jijo chacko4019
3. Lokesh M2283
4. jayantg1474

Active Coders

# Coder NameCodes
1. chowsys6
2. Lokesh M2
3. jayantg1
4. jijo chacko1

Refined Tags

 

Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact  

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape