PHP Classes

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    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 950 This week: 1All time: 3,788 This week: 560Up
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
Age: 50
All time rank: 2434333 in United States United States
Week rank: 411 Up48 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:950
This week:1
All time:3,788
This week:560Up