Check for alphabetic character(s) with ctype_alpha in PHP
Description
The following code shows how to check for alphabetic character(s) with ctype_alpha.
Example
/* w ww. ja va 2 s .c o m*/
<?php
$strings = array('asdf123', 'arf12');
foreach ($strings as $testcase) {
if (ctype_alpha($testcase)) {
echo "The string $testcase consists of all letters.\n";
} else {
echo "The string $testcase does not consist of all letters.\n";
}
}
?>
The code above generates the following result.