note 35655 deleted from function.dechex by pollita
| From: | pollita@php.net | Date: | Wed, 10 Sep 2003 01:10:44 +0000 |
| Subject: | note 35655 deleted from function.dechex by pollita | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-55910@lists.php.net to get a copy of this message | ||
Note Submitter: brian.bush@alltel.com
----
Yet another way to calculate the hexadecimal value of a decimal number of nearly any size:
function dec2hex($dec)
{
$_output = null;
$_hex_values = array(
"0","1","2","3","4","5","6","7",
"8","9","A","B","C","D","E","F"
);
for( $_i = $dec; $_i > 0; $_i = bcdiv($_i,16) )
{
$_output = $_hex_values[bcmod($_i,16)] . $_output;
}
return $_output;
}
--brian