You can make use of the ctype
functions on PHP
ctype_alpha
and ctype_digit
is probably what you are looking for.
Usage:
//For alphabets
if(ctype_alpha('helloworld'))
{
echo "Yeah this is text";
}
//For digits...
if(ctype_digit('45'))
{
echo "Yeah this is a number";
}
1
solved How to check string contain A-Z or a-z or 0-9 in a string?(php) [closed]