Results 1 to 4 of 4
  1. #1

    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,
    Matt
    Regards,
    Matt Fogleman AIM: HstGrid
    The Host-Grid team
    http://www.host-grid.com/

  2. #2
    Join Date
    Dec 2002
    Posts
    246
    PHP Code:
    function is_char($chr) {
      return 
    ereg([a-zA-Z],$chr);


  3. #3
    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 net
    Last edited by Lagniappe-labgeek; 06-27-2003 at 03:52 PM.

  4. #4
    Thanks fellas, I got it!
    Regards,
    Matt Fogleman AIM: HstGrid
    The Host-Grid team
    http://www.host-grid.com/

  5. Newsletters

    Subscribe Now & Get The WHT Quick Start Guide!

Related Posts from theWHIR.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •