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 $mask is in $cat\n<br>"; } } here i didn't have to 'or' the IDs but it works fine and i didn't really understand how it works? what does it mean "if 2 & 15, 2 can be found in 15"???!!! is that a miracle;) thank you bob... --- bob parker <[EMAIL PROTECTED]> wrote: > On Sun, 22 Sep 2002 01:10, you wrote: > > 1. To do that you should 'or' the categories when > the ID's are > to be in more than one category, not add them > eg $category = $cat1 | $cat2; > > 2. To extract the categories within a compounded > category > use the 'and' operator '&' > > eg > > for ($mask=1; $mask <= 64; /*or whatever*/ $mask *= > 2; ) { > if ( $mask & $category ) { > print "Yes $mask is in $category\n"; > } > } original--- > > 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 programming. so, > how > > can i resolve the original IDs. i mean what kind > of > > script can tell me what+what1+what2...whatN = 79? __________________________________________________ Do you Yahoo!? New DSL Internet Access from SBC & Yahoo! http://sbc.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php