note 15227 added to function.pack
| From: | master at dreamphp dot com | Date: | Sun, 02 Sep 2001 08:48:20 +0000 |
| Subject: | note 15227 added to function.pack | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-17530@lists.php.net to get a copy of this message | ||
^-^ Simple version.
function bin2asc ($temp) {
$len = strlen($temp);
for ($i=0;$i<$len;$i+=8) $data.=chr(bindec(substr($temp,$i,8)));
return $data;
}
function asc2bin ($temp) {
$len = strlen($temp);
for ($i=0; $i<$len; $i++) $data.=sprintf("%08b",ord(substr($temp,$i,1)));
return $data;
}
http://www.php.net/manual/en/function.pack.php