How to use ctype_alpha() to checks if all of the characters in a string are alphabetic in PHP

1 Answer

0 votes
$str = array('ABCEExyzQQ', 'wwww@$%%879OOP');
foreach ($str as $s) 
{
    if (ctype_alpha($s)) 
        echo "string: $s - include only letters (alphabetic) <br />";
    else 
        echo "string: $s - NOT include only letters (alphabetic)<br />";
}


/*
run: 

string: ABCEExyzQQ - include only letters (alphabetic)
string: wwww@$%%879OOP - NOT include only letters (alphabetic)

*/

 



answered Jun 6, 2016 by avibootz
...