Login   Register  
PHP Classes

Bitmask Magic: Generate bitmasks for storing options.

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  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 (9 years ago) RSS 2.0 feedNot enough user ratingsTotal: 915 This week: 1All time: 3,628 This week: 1,364Up
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.


- 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
Age: 41
All time rank: 2250283 in United States United States
Week rank: 1060 Up101 in United States United States Up

  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:915All time:3,628
 This week:1This week:1,364Up