heeelp, using & and binary schemes
Posted: Sat Apr 15, 2006 3:09 pm
Hey guys, im stuck again xD... mainly with an area of PHP i never explored or wanted to 
Basicly it involves the '&' and '^' maths thingys.
correct me if im wrong, but i belive ^ is the same as 'to the power of' (e.g. 2^4 = 2*2*2*2)
Yes?
If so, im happy with that
The only thing i cant get my head around is: the & thingy, ive seen it used like:
but i have NO IDEA what the hell this does!.
My final question is, i want to use a 'binary scheme' like:
so i could do:
4+8+64 = 76 (can add, can view, and has donated.)
now i have that number (76) in the database col 'perms'.
how do i turn that 76 BACK into 4+8+64? i know lots of software that does it... ive always wanted to be able to do it, but never researched it xD heeelp
Basicly it involves the '&' and '^' maths thingys.
correct me if im wrong, but i belive ^ is the same as 'to the power of' (e.g. 2^4 = 2*2*2*2)
Yes?
If so, im happy with that
The only thing i cant get my head around is: the & thingy, ive seen it used like:
Code: Select all
echo 32 & 128;My final question is, i want to use a 'binary scheme' like:
Code: Select all
$perms = array(
'candelete' => 1,
'canedit' => 2
'canadd' => 4,
'canview' => 8,
'canbackup' => 16,
'acp_access' => 32,
'donated' => 64,
'fancystars' => 128,
ect.
);4+8+64 = 76 (can add, can view, and has donated.)
now i have that number (76) in the database col 'perms'.
how do i turn that 76 BACK into 4+8+64? i know lots of software that does it... ive always wanted to be able to do it, but never researched it xD heeelp