note 72141 added to function.dechex
| From: | black_m4niac at yahoo dot com | Date: | Thu, 04 Jan 2007 13:08:32 +0000 |
| Subject: | note 72141 added to function.dechex | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-121279@lists.php.net to get a copy of this message | ||
<?
function dec2hex($dec)
{
$dec=intval($dec);
for($i=0;$i<=11;$i++)
if($dec > pow(16,$i) && $dec < pow(16,$i+1))
$pow=$i;
$hex="";
while($pow>=0)
{
$cat=intval($dec/pow(16,$pow));
switch( intval($dec/pow(16,$pow)) )
{
case 10:
$hex.="a";
break;
case 11:
$hex.="b";
break;
case 12:
$hex.="c";
break;
case 13:
$hex.="d";
break;
case 14:
$hex.="e";
break;
case 15:
$hex.="f";
break;
default:
$hex.=$cat;
}
$dec-=$cat*pow(16,$pow);
$pow--;
}
return $hex;
}
echo "dec2hex('2007') - ".dec2hex('2007');
echo "<br>dec2hex(2007) - ".dec2hex(2007);
echo "<br>dechex(2007) - ".dechex(2007);
?>
----
Server IP: 66.163.161.117
Probable Submitter: 194.88.194.36
----
Manual Page -- http://www.php.net/manual/en/function.dechex.php
Edit -- https://master.php.net/note/edit/72141
Del: integrated -- https://master.php.net/note/delete/72141/integrated
Del: useless -- https://master.php.net/note/delete/72141/useless
Del: bad code -- https://master.php.net/note/delete/72141/bad+code
Del: spam -- https://master.php.net/note/delete/72141/spam
Del: non-english -- https://master.php.net/note/delete/72141/non-english
Del: in docs -- https://master.php.net/note/delete/72141/in+docs
Del: other reasons-- https://master.php.net/note/delete/72141
Reject -- https://master.php.net/note/reject/72141
Search -- https://master.php.net/manage/user-notes.php