Results 1 to 4 of 4
Thread: php function: ischar()
-
06-27-2003, 03:11 PM #1Junior Guru Wannabe
- Join Date
- Dec 2002
- Posts
- 53
php function: ischar()
is there a php function anyone knows of that will tell me if a character is a letter?
for example if the character is '0' or 'd' or 'b' it would return TRUE but if the character was ';' or '{' then it would return FALSE
thanks,
MattRegards,
Matt Fogleman AIM: HstGrid
The Host-Grid team
http://www.host-grid.com/
-
06-27-2003, 03:23 PM #2Junior Guru
- Join Date
- Dec 2002
- Posts
- 246
PHP Code:function is_char($chr) {
return ereg([a-zA-Z],$chr);
}
-
06-27-2003, 03:47 PM #3Web Hosting Guru
- Join Date
- Jul 2002
- Location
- The Big Easy -New Orleans
- Posts
- 341
ctype_alpha(sting) - true for [a-z or A-Z] checks whole string.
May also want to see the others:
ctype_alnum -- Check for alphanumeric character(s)
ctype_alpha -- Check for alphabetic character(s)
ctype_cntrl -- Check for control character(s)
ctype_digit -- Check for numeric character(s)
ctype_graph -- Check for any printable character(s) except space
ctype_lower -- Check for lowercase character(s)
ctype_print -- Check for printable character(s)
ctype_punct -- Check for any printable character which is not whitespace or an alphanumeric character
ctype_space -- Check for whitespace character(s)
ctype_upper -- Check for uppercase character(s)
ctype_xdigit -- Check for character(s) representing a hexadecimal digit
http://www.php.net/manual/en/ref.ctype.php
From that page --
Editors note:
CTYPE functions are always prefered, when possible, to Regular Expressions and, often, even to some equivalent str_*, is_* functions. This is because of the fact that CTYPE uses a native C library and thus processes signitificaly faster.
Maxim Maletsky
maxim at php dot netLast edited by Lagniappe-labgeek; 06-27-2003 at 03:52 PM.
-
06-27-2003, 03:50 PM #4Junior Guru Wannabe
- Join Date
- Dec 2002
- Posts
- 53
Thanks fellas, I got it!
Regards,
Matt Fogleman AIM: HstGrid
The Host-Grid team
http://www.host-grid.com/