Word Filter Function
May 2nd, 2008 | posted by Anonymous
Usage :
in
using this function we can filter bad words in sentences
<?php function wordfilter($sentence) { $badlist = array ("dog","pig","monkey"); foreach($badlist as $badword){ $change=""; $wordcensor = preg_split('//', $badword, -1, PREG_SPLIT_NO_EMPTY); // split word into character foreach ($wordcensor as $key => $crctr ) { // char checking $crctr = eregi_replace("([aiueo])","*",$crctr); // change vowels into * $change.=$crctr; //join char into word } $sentence = eregi_replace ($badword,$change,$sentence); } return $sentence; } ?>
Usage :
$sentence = "There are monkey, dog, cat, pig in backyard"; echo wordfilter($sentence); // Output // There are m*nk*y, d*g, cat, p*g in backyard











Post new comment