note 51375 deleted from function.hexdec by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 10:17:21 +0000 |
| Subject: | note 51375 deleted from function.hexdec by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-196978@lists.php.net to get a copy of this message | ||
Note Submitter: rledger at gmail dot com
----
To convert a cellular ESN from hexadecimal to decimal, use the following code. The base conversion
is different due to the fact that the first two characters of a hexadecimal value must be converted
seperately from the remaining six characters.
<?
function esnhexdec($hex){
$a = sprintf("%03d", hexdec(substr($hex, 0, 2)));
$b = sprintf("%08d", hexdec(substr($hex, 2, 6)));
return $a . $b;
}
?>