English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP ctype_alpha() Function Usage and Example

PHP Ctype Function Manual

The ctype_alpha() function checks if all characters in the string are letters

Syntax

ctype_alpha($text);

Definition and Usage

It checks if all characters in the provided string are letters.

Parameter

Serial NumberParameters and Description
1

text(Required)

String to be tested

Return value

 If each character in the text is a letter in the current locale, it returns TRUE, otherwise it returns FALSE.

Online Example

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.

PHP Ctype Function Manual