Search:
Main Menu
Login | RSS |

Quick PHP Code Tips and Examples

PHP Programming Tips, Tutorials and Source Code Examples for newbie

Detect Alphabet only string with ctype_alpha

June 5th, 2008 by Jon Moffet

There are times when you need a function that can detect strings which contains onlyalphabetic characters. While is_numeric can validate a given string contains numeric character, there are no is_* function variation exist which can do the same for alphabetic strings.

However, you can still test for alphabetic string using ctype_alpha() function. Example usage :

CODE:
  1. if (ctype_alpha($testcase)) {
  2.         echo "The string $testcase consists of all letters.\n";
  3.     } else {
  4.         echo "The string $testcase does not consist of all letters.\n";
  5.     }
  6. }

Good luck, and happy coding.

Bookmark Post:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • NewsVine
  • Reddit
  • Netvouz
  • Spurl
  • Furl
  • digg
  • YahooMyWeb
  • del.icio.us

Posted in Uncategorized |

Related Posts

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.