Bit Level

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
calcop
Forum Newbie
Posts: 20
Joined: Fri Mar 04, 2005 2:13 pm

Bit Level

Post 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)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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..
Post Reply