> > In a message dated 19/01/2001 19:03:13 GMT Standard Time,
> > [EMAIL PROTECTED] writes:
> >
> > << Use a database for the words and say "SELECT 1 WHERE
LOWERCASE('$name')
> > LIKE
> > '%'+word+'%'" and count how many rows are returned. No need to
re-invent the
> > wheel.
> >
> > --
> > Ignacio Vazquez-Abrams >>
> >
> >
> > Yeah problem is he has no database support from his host
> >
> > Ade
> >
>
> Ouch. All is not lost, however:
>
> $words=Array(
> "f***",
> "s***",
> ...
> ); // Or use file() to read them from a file.
>
> ...
>
> $done=false;
> while ((list($key, $val)=each($words)) and $done===false)
> {
> $done=strpos(strtolower($name), $val);
> };
> if ($done!==false)
> {
> // Oops! Bad name.
> }
> else
> {
> // Okay, valid name.
> };
>
all that code, well, geez. why not store the words in a file, space
delimited, then:
if (preg_match("/" . implode(" ", file($prof_file)) . "/i", $text)) {
print("Naughty man");
} else {
print("Well, fuck, you're curse free! Congrats...");
}
Or just store it in a string and omit the implode and file() function calls
(I'd prefer placing it in a file for easy addition of new curses)...
If you go with the other method (described by Ignacio), see the in_array()
function, which saves you the trouble of looping...
-Sterling
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]