Oh, i'm so sorry. I wrote the last code hastily. Here is a much more revised one (it works: i tested it :-)
<?php
$membername = $character;
$words = file("vulgar.txt");
$badname = false;
for($i = 0; $i < sizeof($words); $i++) {
$words[$i] = chop($words[$i]);
if(eregi($words[$i], $membername)) {
$badname = true;
break;
}
}
if($badname == true) {
print "Sorry, invalid";
}
else {
print "valid!";
}
?>
Okay, basically if it find that they have a bad word, it sets the $badname flag as true. So once we break out of the for loop, we can see if the loop found a bad word (if badname == true). Else, its valid!
Please try it out and let me know. I'm sorry for the glitches in the previous code.
-sridhar