In order to filter a text given by a textarea form, I use this following function.
Problems are:
- filtering with my list of noisy words in noise.txt (one word per line) doesn't work
- I have to filter twice the text to eliminate the one-letter's words
Thank you for your help !
<?
function filter($texte)
{
$texte = strtolower($texte) ;
$texte = strip_tags($texte) ;
$texte = ereg_replace("[[:alpha:][:space:]]"," ",$texte) ;
$texte = ereg_replace(""," ", $texte) ;
$filter = file("noise.txt");
for( $i=0 ; $i < count($filter) ; $i++ )
$texte = ereg_replace( " ".trim($filter[$i])." ", " ", $texte) ;
unset($filter);
$texte = ereg_replace(" (.){1,2} ", " ", $texte);
$texte = ereg_replace("[[:space:]]+"," ",$texte) ;
return $texte;
}
?>