PHP 检查字符或者字符串 是否仅包含指定类型的字符 ctype 系列函数

$strings = array('AbCd1zyZ9', 'foo!#$bar');
foreach ($strings as $testcase) {
    if (ctype_alnum($testcase)) {
        echo "The string $testcase consists of all letters or digits.\n";
    } else {
        echo "The string $testcase does not consist of all letters or digits.\n";
    }
}

上面只是一个列子,更多请自行查阅

posted @ 2023-05-23 15:11  小鱼大虾  阅读(22)  评论(0)    收藏  举报
本博客只是记录个人学习中遇到的问题.只供自己个人参考!