Valid HEX?
Posted: Sun Jan 29, 2006 10:54 am
How to check if a value is valid HEX?
Code: Select all
1234567890abcdef => valid
1234567890abcggg => legalA community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
1234567890abcdef => valid
1234567890abcggg => legalCode: Select all
if (TRUE === preg_match("/[^A-Fa-f0-9]/", $input_string))
echo "Not a hexadecimal!!!";Actually, in many systems, hex is case sensitive - it must be lowercase.raghavan20 wrote:Code: Select all
if (TRUE === preg_match("/[^A-Fa-f0-9]/", $input_string)) echo "Not a hexadecimal!!!";
Code: Select all
if (TRUE === preg_match("/[^a-f0-9]/", $input_string))
echo "Not a hexadecimal!!!";Code: Select all
if (TRUE == preg_match("/[^A-Fa-f0-9]/", $input_string)) echo "Not a hexadecimal!!!";Code: Select all
$returnValue = preg_match("/[^A-Fa-f0-9]/", $input_string) ;
if ( $returnValue == 0 || returnValue === FALSE )
echo "Not a hexadecimal!!!";Code: Select all
dechex(hexdec('AF'))