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 programming. so, how > can i resolve the original IDs. i mean what kind of > script can tell me what+what1+what2...whatN = 79?
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"; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php