Yeah, I decided to do some research.
Based on my understanding on what Perl does, here's the unoptimised PHP equivalent:
function packB($str) {
$len = strlen($str);
$ret = 0;
$n = $len - 1;
for ($i = 0; $i < $len; $i++) {
if ($str{$i} != '0')
$ret += pow(2, $n);
$n--;
}
return $ret;
}
My understanding is that B* takes a string composed of '0's and '1's and returns an integer.
EDIT:
nope, this doesnt do what is needed (i.e. packing into bit string).