hexdec

Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Hexadecimal to decimal
<?php hexdec(string $hex_string): int|float
<?php         if (preg_match($hexPattern, $value, $matches)) {

            $result = [];

            $result[0] = strlen($matches[1]) == '1' ? hexdec($matches[1].$matches[1]) : hexdec($matches[1]);

            $result[1] = strlen($matches[2]) == '1' ? hexdec($matches[2].$matches[2]) : hexdec($matches[2]);

            $result[2] = strlen($matches[3]) == '1' ? hexdec($matches[3].$matches[3]) : hexdec($matches[3]);

            $result[3] = 1;
<?php         if (preg_match($hexPattern, $value, $matches)) {

            $result = [];

            $result[0] = strlen($matches[1]) == '1' ? hexdec($matches[1].$matches[1]) : hexdec($matches[1]);

            $result[1] = strlen($matches[2]) == '1' ? hexdec($matches[2].$matches[2]) : hexdec($matches[2]);

            $result[2] = strlen($matches[3]) == '1' ? hexdec($matches[3].$matches[3]) : hexdec($matches[3]);

            $result[3] = 1;

        } elseif (preg_match($rgbPattern, $value, $matches)) {
<?php             $result = [];

            $result[0] = strlen($matches[1]) == '1' ? hexdec($matches[1].$matches[1]) : hexdec($matches[1]);

            $result[1] = strlen($matches[2]) == '1' ? hexdec($matches[2].$matches[2]) : hexdec($matches[2]);

            $result[2] = strlen($matches[3]) == '1' ? hexdec($matches[3].$matches[3]) : hexdec($matches[3]);

            $result[3] = 1;

        } elseif (preg_match($rgbPattern, $value, $matches)) {

            $result = [];
<?php             return false;

        }



        if (\hexdec($codepoint) > 1114111) {


            return false;

        }
<?php                         $l = strlen($match[1]);



                        if ($l % 2) {

                            $code = hexdec($match[2]);



                            if (0xD800 <= $code && 0xDFFF >= $code) {
<?php                 throw new InvalidArgumentException(sprintf('Invalid "%s" color.', $color));

            }



            return ($background ? '4' : '3') . $this->convertHexColorToAnsi(hexdec($color));

        }



        if (isset(self::COLORS[$color])) {