php - Set and Check two bit flags -
what want do:
have 4 conditions. maximum 2 set. there maximal 4 valid combinations.
$types = array( "a" => 0x1, "b" => 0x2, "c" => 0x4, "d" => 0x8, );
we can have a/b + c/d (=ac, ad, bc, bd)
$flags = $types["a"] | $types["c"]; if ($flags & ($types['a'] | $types['d'])) echo "true"; else echo "false"; // output: "true"
okay i'm fiddling around .. way long.
how set , check 2 flags correctly?
// pseudo code explanation x = + d if(x = a+c)
Comments
Post a Comment