Forum Moderators: coopster
Are you going to allow any blanks in the user names? Blanks will throw you for a loop, too. This example does not allow blanks:
$names = array('bad one', 'good_1', '', ' ', 'bad-one');
foreach ($names as $key => $name) {
// Bad names:
if (!$name or preg_match("/[^[:alnum:]_]/", $name)) print "$key: $name\n";
}
// Prints out the bad names:
0: badone
2:
3:
4: bad-oneUse this to play around and learn more about regular expressions. The tutorials in the links provided earlier will help you get a better grip on them. Daunting at first, but awesome once you get a grip on them.