PHP Code

Print binary data as a string with PHP

Here's a cool little function that takes binary data and outputs it as a regular string.

function bin2string($bin) {
   $res = "";
   for($p=31; $p >= 0; $p--) {
     $res .= ($bin & (1 << $p)) ? "1" : "0";
   return $res;

Leave a Reply

Your email address will not be published. Required fields are marked *

To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image