The bitwise & creates an output where the bits that are set in both the input and output are set.
Here is the example detailed (using 8bit values for simplicity's sake).
for($i=0;$i<5;$i++) {
if($i & 1)
echo 'here 1<br />';
else
echo 'here 2<br />';
} //end for
Okay there is the code now let's take a look under the hood at what's really going on.
First pass, $i = 0
00000000 & 00000001 = 00000000
This is false so the else executes
Second pass, $i = 1
00000001 & 00000001 = 00000001
This is true so the if executes
Third pass, $i = 2
00000010 & 00000001 = 00000000
This is false so the else executes
Fourth pass, $i = 3
00000011 & 00000001 = 00000001
This is true so the if executes
Fifth pass, $i = 4
00000100 & 00000001 = 00000000
This is false so the else executes
Try echoing out the ids maybe that is the problem you're running into. Or it could even be a signed vs. unsigned problem.