Page 1 of 1

Resolved: PHP and Hexadecimal

Posted: Mon Jul 16, 2007 6:53 am
by thomas777neo
Good Day

Does anyone have a class that outputs the iteration of hex values according to a range?

E.g. 520-52f

I need to get a list of the values within that range.

Like

520
521
522
... for the 16 values

Posted: Mon Jul 16, 2007 6:55 am
by feyd
You can use range() + array_map() + dechex()

Posted: Mon Jul 16, 2007 7:14 am
by thomas777neo
Thanks feyd, never had to use the range function yet (quite an obvious one)

Here is the quick and dirty version so far:

Code: Select all

$start_range = hexdec("0520");
$end_range = hexdec("052f");
	
foreach (range($start_range,$end_range) as $number) 
{
    $dechex = dechex($number);
} // foreach (range($start_range,$end_range) as $number)
Works just fine for now. Thanks again.