我有一个PHP两个字符串我想让以下检查在分化字母数字和字母在PHP
1) 4f74adce2a4d2 - contains ***alphanumerics***
2) getAllInfo - contains ***only alphabetic***
检查这个我写了一个功能,但任何价值$ PK包含上述中,成果转化 如此而已,但i want to differentiate between alphanumeric and alphabetic only
<?php
if (ereg('[A-Za-z^0-9]', $pk)) {
return true;
} else if (ereg('[A-Za-z0-9]', $pk)) {
return false;
}
?>
你也可以看看这个扩展:http://php.net/ctype – mishu 2012-03-30 14:57:33
al所以pcre建议http://php.net/pcre – mishu 2012-03-30 14:59:01
扩大点@mishu使这些ctype功能看起来更具体http://www.php.net/manual/en/function.ctype-alnum.php http://www.php.net/manual/en/function.ctype-alpha.php – martynthewolf 2012-03-30 15:01:03