Code.GeekInterview.com
 
Code Samples PHP
 

Custom Filtering Unwanted Words


Code ResourceAuthor: Lokesh M  

Difficulty Level:

Published: 25th May 2007   Read: 4258 times  

Filed in: PHP
Add Comment


 

 

Sponsored Links


 

 

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 Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    



Popular Coders

# Coder NameHits
1. chowsys21597
2. jijo chacko9600
3. Lokesh M8357
4. jayantg3232

Active Coders

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

Refined Tags