This may be a really silly question, but it just crossed my mind and I thought it would be interesting to know for sure....
So here is the scenario:
Users have 3 options for each day of the week: AM, PM, and OFF. These are mutually exclusive choices, so there is no option to work both an AM and PM on same day.
So if I wanted to store their AM shifts and PM shifts as separate bitmasks, and User1 chooses the following:
S M T W Th F Sa
A P X A X P A
I would have the following:
$shifts['User1']['AM'] = 73; // 1001001
$shifts['User1']['PM'] = 34; // 0100010
Now, if I just wanted to know which days User1 worked, I could obviously just do:
$shifts['User1']['All'] = $shifts['User1']['AM'] | $shifts['User1']['PM'];
Or even just:
$shifts['User1']['All'] = $shifts['User1']['AM'] + $shifts['User1']['PM'];
But what if I wanted the final result to distinguish AM from PM, something to the effect of:
$shifts['User1']['AM'] = A00A00A;
$shifts['User1']['PM'] = 0P000P0;
So that the A's and P's are both considered set, but that
A00A00A | 0P000P0 = AP0A0PA;
Is there a common way of doing this, or am I thinking about this totally wrong?