note 41692 added to function.bin2hex
| From: | AntonioAlcorn at yahoo dot coma | Date: | Tue, 20 Apr 2004 03:34:31 +0000 |
| Subject: | note 41692 added to function.bin2hex | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-68353@lists.php.net to get a copy of this message | ||
In response to Patrik:
A simpler way to print a number in binary is to use base_convert().
<? echo base_convert($bin, 10, 2); ?>
If you need it to print all 32 bits (as your function does) you can just pad it out:
<? echo str_pad(base_convert($bin, 10, 2), 32, '0', STR_PAD_LEFT); ?>
The conversion is from base 10 because when $bin is passed to base_convert(), it is converted to a
string, and the default representation is in decimal.
Hope this helps.
----
Manual Page -- http://www.php.net/manual/en/function.bin2hex.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41692
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41692&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41692&report=yes
Search -- http://master.php.net/manage/user-notes.php