I have a roles table on my database that was set in a binary sequence:
1-Admin
2-Teacher
4-Student
8-Principal
16-Parent
32-Guest
more..
more..
There are times an admin can be a teacher so his role will be 3 (1+2), as well as a principal can also be a teacher with the role:10 (8+2). This way I can setup variety of roles such as Guest+Parent=48. Hope you get the idea. Now, adding roles in PHP and inserting them into the database is easy. Now, my question is: how do I extract roles individually from the whole number. For example, if a person's role is 44, how can I get in PHP that this person is a (Guest), (Principal), and (Student). (Please disregard the logic of a student can not be a parent for this question.) Is there a PHP function for this?