Re: check for alphanumeric characters
| From: | John Nichel | Date: | Fri, 29 Apr 2005 16:14:43 +0000 |
| Subject: | Re: check for alphanumeric characters | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-214217@lists.php.net to get a copy of this message | ||
Philip Hallstrom wrote:
I always forget about the c_type functions. Good call. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 john@kegworks.comwhat kind of a function can I use that will tell me whether a variable is alphanumeric (that is has only characters A-Z or 1-9 )?http://us3.php.net/manual/en/function.ctype-alnum.php bool ctype_alnum ( string text ) Checks if all of the characters in the provided string, text, are alphanumeric. In the standard C locale letters are just [A-Za-z] and the function is equivalent to preg_match('/^[a-z0-9]*$/i', $text). Returns TRUE if every character in text is either a letter or a digit, FALSE otherwise. ---- Note that if you pass in an empty string you'll also get TRUE...