Get array values based on bitmask in PHP
You will need to loop in 32 steps over your mask and test it for '1', if this bit is set, you can copy the element to your resulting array.
Pseudo code:
m = 0x00000001
j = 0
for i in 0 to 31 loop
if ((mask & m) = m) then // bit is set in mask
result(j++) := input(i)
end if
m := m << 1 // shift left by 1 or multiply by 2
end loop