Re: [PHP] algorythm question

2002-09-23 Thread Barýþ
ok, now it's clear why i must use '|' instead of '+'. i still couldn't get what happens with bits but you don't have to explain more. i know that it's about bitwise operators, and how they handle numbers. no! ok! i just got it! thank you again. --- bob parker <[EMAIL PROTECTED]> wrote: > Coupl

Re: [PHP] algorythm question

2002-09-22 Thread Barýþ
oh my god. here is an example. $userLevels = array( 1 => 'Member', 2 => 'Admin', 4 => 'Writer', 8 => 'Expert'); $cat = 15; for ($mask=1; $mask <= 64; $mask *= 2) { if ( $mask & $cat ) { print "Yes $mas

Re: [PHP] algorythm question

2002-09-21 Thread bob parker
On Sun, 22 Sep 2002 01:10, you wrote: > consider there are categories and these have IDs like > below: > 1, 2, 4, 8, 16, 32, 64... > > if some data belongs to more than 1 category for > exemple 4 and 32, its category ID will be 36, the sum > of cat. IDs. > i guess this is used widely in programmin