Codice PHP:
//load list of common words
$common = file('stopwords.txt');
$total = count($common);
for ($x=0; $x < $total; $x++)
$common[$x] = trim(strtolower($common[$x]));
function stopWords($term)
{
global $common;
$clean_term = '';
$term = ereg_replace("[[:punct:]]"," ",$term);
$_terms = explode(" ", $term);
foreach ($_terms as $line)
{
if (in_array(strtolower(trim($line)), $common))
$clean_term .= " XXXXX ";
else
$clean_term .= " ".$line;
}
return $clean_term;
}
$contatore = 0;
$textfile = fopen("public/bacheca/db/messaggi.txt", "r");
while ($rigafile = fgets($textfile,1024))
{
$campiriga = explode("|", $rigafile);
$messaggioCensurato= stopWords($campiriga[4]);
echo "- $campiriga[1]-$messaggioCensurato-[b]$campiriga[2][/b]
";
}
fclose($textfile);
?>
Sono notifiche, non errori.
Non ho capito quello del punto trasformato in XXX.
Fammi un esempio di un messaggio, le parole che hai messo nel file txt e del risultato.