function check_bit($bin, $bit)
{
if($bit < 0 || $bit > strlen($bin)) { return -1; } // bit out of range
else if(strlen($bin) != (substr_count($bin, "1")+substr_count($bin, "0"))) { return -1; } // invalid bit - non 0/1 bits set
else { return substr($bin, $bit, 1); }
}
something that simple should work.... then to check your bit...
1's: if (check_bit($mybitvar, $mybitnum)) { do this for a value of 1; }
0's: if (!check_bit($mybitvar, $mybitnum)) { do this for NOT value of 1 ie a return of 0; }
HTH
edit: added some error checking into it... hopefully the substr_count check works... couldnt think of a better way to do it....