Page 1 of 1

Bit Level

Posted: Fri Mar 04, 2005 2:20 pm
by calcop
Hi everyone, I was hoping someone could help me. I've already tried searching Google and php.net and cannot find the answer to my question.

Anyway, I need help on what function(s) to use to write and read from files at the bit level. For example, I am trying to move a windows database solution over to all php. I need to be able to read and write to the files. One such file has a layout of:

Bits 1 - Account active (0 - no, 1 - yes)
Bits 2-16 - Pin number.

Anyway, I needt o be able to write at bitlevel and read at bit level. Another reason is for compression of text files. I will need to use the same algoritum as the windows source, so I will not be able to use the built-in compression libraries.

Thanks for your help! 8)

Posted: Fri Mar 04, 2005 2:51 pm
by feyd
the bitwise operators.. << >> & ~ | ^ .. you can also use unpack() to break out each bit into a 1/0 string.

you'll have to read and write in byte blocks..