[thelist] PHP: is_numeric... that's the question...

Drew Trusz drew.trusz at gmail.com
Thu Jan 18 06:05:55 CST 2007

> anyhoo, next I wanna check to see if a usercode is only numeric, and
> 1-8 characters long..

> I tried:
> return preg_match("[^a-zA-Z][0-9]{1,8}", $usercode);
> But it was accepted if there were any numbers in teh text.. that's bad!
> thoughts?
Don't look for alphas when you want numeric. You don't want a match on
[a-zA-Z] only on 0-9 with the appropriate length.

Nice to see Szasz quoted.


More information about the thelist mailing list