Okay, here's something I whacked together. I'm not thrilled by it - the thought of using a whole byte to store one bit is mildly offensive - but it can be thought of as an intermediate stage.
function bitsequence_to_string($word)
{
$array = unpack("H*hex", $word);
$hex = $array['hex'];
$nibbles = array(
'0' => '0000', '1' => '0001', '2' => '0010', '3' => '0011',
'4' => '0100', '5' => '0101', '6' => '0110', '7' => '0111',
'8' => '1000', '9' => '1001', 'a' => '1010', 'b' => '1011',
'c' => '1100', 'd' => '1101', 'e' => '1110', 'f' => '1111');
$binary = strtr($hex, $nibbles);
return $binary;
}
Now the string functions can be used to chop that up and extract chunks and compare bits and whatever else. If you want to convert a string of bit characters into a number, [man]bindec[/man] will make the conversion (but watch out for overflow!).