alexislalas Posted May 18, 2009 Share Posted May 18, 2009 Hello, I have a pool of values I have to use, but I only have the first and last value of the range: 9CF90000-9CF910CB and I need all the values between them. How can I get them or generate them? Thanks!! Link to comment https://forums.phpfreaks.com/topic/158629-generating-hexadecimal-values/ Share on other sites More sharing options...
kickstart Posted May 18, 2009 Share Posted May 18, 2009 Hi $startNum = hexdec("9CF90000"); $endNum = hexdec("9CF910CB"); for($iCnt = $startNum; $iCnt <= $endNum; $iCnt++); { echo dechex($iCnt); } All the best Keith Link to comment https://forums.phpfreaks.com/topic/158629-generating-hexadecimal-values/#findComment-836607 Share on other sites More sharing options...
Psycho Posted May 18, 2009 Share Posted May 18, 2009 kickstart beat me to it, but I created a function (plus his has a typo because of the [ code ] tag), so I'll post mine anyway: <?php function getHexRange($start, $end) { $startDec = hexdec($start); $endDec = hexdec($end); $hexArray = array(); for($dec=$startDec; $dec<=$endDec; $dec++) { $hexArray[] = dechex($dec); } return $hexArray; } $range = getHexRange('9CF90000', '9CF910CB'); print_r($range); ?> Link to comment https://forums.phpfreaks.com/topic/158629-generating-hexadecimal-values/#findComment-836610 Share on other sites More sharing options...
kickstart Posted May 18, 2009 Share Posted May 18, 2009 Whistles nonchalantly. All the best Keith Link to comment https://forums.phpfreaks.com/topic/158629-generating-hexadecimal-values/#findComment-836612 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.