【问题标题】:Ctype function for both alphabetic and nummeric inputs用于字母和数字输入的 Ctype 函数
【发布时间】:2018-07-02 03:04:40
【问题描述】:

有没有办法用 Ctype 检查输入是否同时包含字母和数字字符?

【问题讨论】:

  • 你试过ctype_alnum 函数吗?

标签: php ctype


【解决方案1】:

ctype_alnum

<?php
$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";
    }
}
?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-08
    • 2017-01-26
    • 1970-01-01
    • 1970-01-01
    • 2011-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多