ctype_xdigit

(PHP 4 >= 4.0.4, PHP 5)

ctype_xdigit --  16進数を表す文字かどうかを調べる

説明

bool ctype_xdigit ( string c)

textの全ての文字が16進数を表す文字、つまり、数字または [A-Fa-f] である場合に TRUE、 それ以外の場合に FALSE を返します。

例 1. ctype_xdigit() の例

<?php
$strings
= array('AB10BC99', 'AR1012', 'ab12bc99');
foreach (
$strings as $testcase) {
    if (
ctype_xdigit($testcase)) {
        echo
"The string $testcase consists of all hexadecimal digits.\n";
    } else {
        echo
"The string $testcase does not consist of all hexadecimal digits.\n";
    }
}
?>

この例の出力は以下のようになります。

The string AB10BC99 consists of all hexadecimal digits.
The string AR1012 does not consist of all hexadecimal digits.
The string ab12bc99 consists of all hexadecimal digits.

ctype_digit() も参照して下さい。