Alphabetic equivalent of PHP is_numeric

I am looking for a function that will be the literal equivalent of is_numeric. It will return true if the string contains only letters, and false otherwise. Is there a built-in function in PHP?

+3
source share
4 answers

Do you want to ctype_alpha()

+10
source

If you are strictly looking for the opposite is_numeric(), would not do the !is_numeric()job for you? Or do I not understand the question?

+1
source

I would use preg_match. But that is because I never heard of ctype_alpha().

if(!preg_match("/[^a-zA-Z]/", $teststring)) {
    echo "There are only letters in this string";
} else {
    echo "There are non-letters in this string";
}
0
source

!is_numeric((float)$variableToBeChecked); also preg_match('#^[a-z]+$#i',$variableToBeChecked); // for one or more letter character

0
source

Source: https://habr.com/ru/post/1734182/


All Articles