M999 M999 - 1 year ago 78
PHP Question

How to store indices of an array in an interger?

I have an array as follows:

$categories = [
0 => 'a',
1 => 'b',
2 => 'c',
3 => 'd',
4 => 'e',
5 => 'f',

Is there a way to use an integer variable that can store multiple indexes of $categories?


$x = a (an integer number). It means $x contains 0, 1
$x = b (an integer number). It means $x contains 1, 2

Could anyone tell me how to do it?

Answer Source

Try Bitwise operators. Bitwise operators allow evaluation and manipulation of specific bits within an integer.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download