On Sat, 20 Jan 2001 [EMAIL PROTECTED] wrote:
> Ok,
>
> I am now using the following code to check if there is any profanity in the
> $FirstName however it just doesn`t work when testing, I am thinking it has
> something to do with the way I`m loading the file, any better ways.
>
> $words=file('words.txt');
> $done=false;
> while ((list($key, $val)=each($words)) and $done==false)
> {
> $done=strpos(strtolower($FirstName), $val);
> };
> if (!$done==false)
> {
> echo "Oops! Bad name";
> }
> else
> {
> echo"Okay, valid name.";
> };
>
It may have to do with the fact that you're using == in the while instead of
=== to also include type checking. If you're using PHP 3 you should say
!strlen($done), otherwise the while clause will be true if the profane word
starts at the beginning of the string (position 0).
--
Ignacio Vazquez-Abrams <[EMAIL PROTECTED]>
--
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]