From 05f182908157a56b1489f543f251be62af501ba4 Mon Sep 17 00:00:00 2001 From: Andrey Knupp Vital Date: Tue, 22 Oct 2013 21:32:57 -0200 Subject: [PATCH] Improving is_hex function. --- lib/Unirest/Unirest.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/Unirest/Unirest.php b/lib/Unirest/Unirest.php index e77f0d0..8c636ac 100644 --- a/lib/Unirest/Unirest.php +++ b/lib/Unirest/Unirest.php @@ -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); }