note 35655 added to function.dechex
| From: | brian dot bush at alltel dot com | Date: | Tue, 09 Sep 2003 23:40:08 +0000 |
| Subject: | note 35655 added to function.dechex | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-55908@lists.php.net to get a copy of this message | ||
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
----
Manual Page -- http://www.php.net/manual/en/function.dechex.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35655
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35655&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35655&report=yes