2013-12-10 308 views

回答

1

您可以使用的功能ctype上PHP

ctype_alphactype_digit可能是你在找什么。

用法:

//For alphabets 
if(ctype_alpha('helloworld')) 
{ 
echo "Yeah this is text"; 
} 
//For digits... 
if(ctype_digit('45')) 
{ 
echo "Yeah this is a number"; 
} 
+1

谢谢!酷功能! – user2837851

0

您可以使用正则表达式是:

$string = "abasdfBSDFSDFJKJH23409283049"; 
if (preg_match("^/[A-Za-z0-9]$/", $string)) 
{ 
    //it matches 
} 
相关问题