Many PHP functions use constants with integer values for flags. Hence, an integer value of:
48 = 32, 16
51 = 32, 16, 2, 1
I was curious if there is a php function / class or a more elegant way to reverse the process to break down an integer as I did above, and even better determine the flags associated with the function.
I have thought of setting an associative array like so: [ 'flag name' => int ] and then looping through the array to add up the values of every possible combination, but this seems pretty inefficient. Especially when dealing with as many as 12 flags, then you have millions of combinations.