note 95722 deleted from function.substr by danbrown
| From: | danbrown@php.net | Date: | Mon, 18 Jan 2010 15:09:15 +0000 |
| Subject: | note 95722 deleted from function.substr by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-165078@lists.php.net to get a copy of this message | ||
Note Submitter: maciek108 at poczta dot onet dot pl
----
//censor entries
//cenzor wpisów
<?php
function cenzor($content){
$words_list=@file('test.txt');//file with profanity (after lines)
foreach($words_list as $badword){
$badword=trim($badword);
$badwordtop=substr($badword, 0,2);//2, the first signs
$badwordlength=strlen($badword);
$x=3; // continued from 3 mark
while($x <= $badwordlength){
$badwordtop.='*'; //add *
$x++;
}
$content=str_replace($badword, $badwordtop, $content);
}
return $content; //returning results
}
echo cenzor($_POST['content']);
//example:
//$_POST['content'] includes the word home
//If the file test.txt would be the word home
//the emergence of words home - ho**
?>