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.p
hp.net/note/edit/63787
Del: integrated -- ht
tp://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://m
aster.php.net/note/delete/63787/spam
Del: non-english -- h
ttp://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://ma
ster.php.net/manage/user-notes.php
--
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php
|