function check() /* Establishes the function check */
{
global $text; /* Gets All Variables */
//To Add New Words, Just Copy One Line From Below And Paste It Below The Third Line. Just Replace the first word in quotes with the word you would like, and the second word in quotes to what you would like to change it to.//
$text = str_replace("hey","****",$text); /* Replaces the word "hey" into "****" */
$text = str_replace("pie","****",$text);
$text = str_replace("php","***",$text);
echo $text;
}
return check(); /* Returns the function check() */
That could be very useful for renaming mistypings and such, thanks for your tutorial!
04-04-2005, 03:10 AM
Peksa
I would code it differently, since replacing each word seperately will be slower than my code here.. (Actually i would use mysql, but i can't be bothered here)
Code:
<?php
function check($string)
{
$replace = array();
$with = array();
This is very useful. I am eventually going to run my own site in about 1 year I should be ready. I don't want to just start a site with out having everything I need. So yea. Good Tutorial. :D
04-08-2006, 10:46 PM
argroups
i have made the bad word filter for filtering my emails.
I would like to know how to make certain email ids avoid this word filter I mean some of my very close friends are blocked by this word filter How to allow them sending mails avoiding this word filter ?
How to code it ?
02-21-2009, 03:27 PM
Karlos
Hmm you certainly now alot /scarasm
example
PHP Code:
<?php
function check($string) { $replace = array(); $with = array();
now lets use that function...
Testing, Popping in to say hey and good test. // Output: monkeying in to say *** and good monkey.
see what i mean? it replaces anything with the letter's joined up i had this problem on a mates forums e.g. class would show cllove as the word ass..
Karlos
02-21-2009, 04:45 PM
Apathy
Nice way to bump a thread from 2005.
02-22-2009, 03:24 AM
Karlos
Tbh i don't care when a thread was started, i like to point out the point and flaws...
And Hello Apathy
06-21-2009, 12:29 AM
jiawei456123
Help
Is it possible to put all the words in a txt file and just matching it to the message(whereby if a badword is detected it just echo a message?) instead of replacing the words? Urgent reply needed
07-06-2010, 11:45 PM
SmoKe^
Actually the most effective way would be to use general word to replace several words. And yes a text file can be used.