php: unpack by bits
===

I want to unpack a binary string into into an array by a weird sequence of 8-8-8-7 bits...

I could easily do something like this, for a normal 8-8-8-8 sequence:

    $b=unpack('C*',$data);
    for ($i=0,$count=sizeof($b); $i < $count; $i+=4) {
	$out[]=array($b[$i+1],$b[$i+2],$b[$i+3],$b[$i+4]);
    }

That would give me a 2D array of bytes, grouped by 4.

But as the fourth being 7 bits, I just can't think of anything appropriate.

...Have you got some ideas?