我有一個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