Improving is_hex function.

This commit is contained in:
Andrey Knupp Vital
2013-10-22 21:32:57 -02:00
parent 3291ca8bce
commit 05f1829081

View File

@@ -180,14 +180,10 @@ if (!function_exists('http_chunked_decode')) {
/**
* determine if a string can represent a number in hexadecimal
*
* @link http://uk1.php.net/ctype_xdigit
* @param string $hex
* @return boolean true if the string is a hex, otherwise false
*/
function is_hex($hex) {
// regex is for weenies
$hex = strtolower(trim(ltrim($hex,"0")));
if (empty($hex)) { $hex = 0; };
$dec = hexdec($hex);
return ($hex == dechex($dec));
return ctype_xdigit($hex);
}