PHP Classes
elePHPant
Icontem

Bitmask Magic: Generate bitmasks for storing options.

Recommend this page to a friend!
  Info   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2005-05-14 (11 years ago) RSS 2.0 feedNot enough user ratingsTotal: 923 All time: 3,724 This week: 867Up
Version License Categories
bitmask 1.0Public DomainMath
Description Author

This class is designed to create bitmasks, which are very commonly used to store lists of true or false values as a single integer.

The class can manpulate bitmasks that are not limited to 32 bits. It does not need the PHP gmp extension to provide arbitrary bit length support.

This absence of limits may encourage the storage of more complex data than merely true or false lists for those that are creative enough to figure it out.

Although PHP programmers commonly rely on databases to do much of the grunt work that is most commonly done by bitmasks in other types of programming, there is nothing better for tracking things such as user permissions, product options, and I have even used them to trace complex data structures.

Features:

- Convert arrays of booleans to bitmasks

- Convert bitmasks to booleans

- Convert bitmasks to arrays of booleans

- Store virtually unlimited bit depth bitmasks in string form

- Query individual bits to see if they are set

- Enter an associative array, manipulate bits and return the array in either the full array or only the values that are set

Picture of Timm Simpkins
Name: Timm Simpkins <contact>
Classes: 1 package by
Country: United States United States

  Files folder image Files  
File Role Description
Plain text file bitmask.class.php Class bitmask class
Accessible without login Plain text file bitmask_example.php Example Example file for bitmask class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:923
This week:0
All time:3,724
This week:867Up