English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The ctype_alpha() function checks if all characters in the string are letters
ctype_alpha($text);
It checks if all characters in the provided string are letters.
Serial Number | Parameters and Description |
---|---|
1 | text(Required) String to be tested |
If each character in the text is a letter in the current locale, it returns TRUE, otherwise it returns FALSE.
Check if the array elements are all letters.
<?php $strings = array('example', 'example1234'); foreach ($strings as $test) { if (ctype_alpha($test)) { echo "$test All are letters.\n"; }else { echo "$test Not all are letters. \n"; } } ?>Test and see‹/›
Output result:
example All are letters. example1234 Not all are letters.