note 63787 added to function.hexdec
| From: | greatwhitepine at NOSPAM dot yahoo dot ca | Date: | Thu, 30 Mar 2006 20:46:40 +0000 |
| Subject: | note 63787 added to function.hexdec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-107048@lists.php.net to get a copy of this message | ||
Hex to binary conversion that works for large and small hex numbers.
<?php
function hexbin($str_hex) {
$str_bin = FALSE;
for ($i=0; $i < strlen($str_hex); $i++) {
$str_bin .= sprintf("%04s", decbin(hexdec($str_hex[$i])));
}
return $str_bin;
}
$str_hex = "effffff20df";
print "\n HEX VALUE: $str_hex\n";
printf(" REAL BINARY VALUE: %50s\n", hexbin($str_hex));
printf("CHOPPED BINARY VALUE: %50s\n\n", decbin(hexdec($str_hex)));
?>
----
Server IP: 216.235.15.211
Probable Submitter: 142.78.191.29
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.hexdec.php
Edit -- http://master.php.net/note/edit/63787
Del: integrated -- http://master.php.net/note/delete/63787/integrated
Del: useless -- http://master.php.net/note/delete/63787/useless
Del: bad code -- http://master.php.net/note/delete/63787/bad+code
Del: spam -- http://master.php.net/note/delete/63787/spam
Del: non-english -- http://master.php.net/note/delete/63787/non-english
Del: in docs -- http://master.php.net/note/delete/63787/in+docs
Del: other reasons-- http://master.php.net/note/delete/63787
Reject -- http://master.php.net/note/reject/63787
Search -- http://master.php.net/manage/user-notes.php