The meaning is : How to store in a single database field, multiple value as, for example, Optin data.
In order to do that, i've to know how to code and decode the value. I've an array with different optin values:
$optin = array (
'1' => 'SMS',
'2' => 'Email',
'4' => 'Mail',
'8' => 'AppsPushNotif',
'16' => 'Partners',
'32' => 'Gaming Partners'
);
ie.: I'll store,in optin field : - '7' if the user is opt-in for SMS,Email and Mail (4+2+1) or - '40' for AppsPushNotif and Gaming_Partners
I would like found a way to decode 7 or 40 values into an array with optin's arrays values.
Many thanks
PS: Thanks to Cyclone for the solution :
$output = '';
$value = 40;
$keys = array_keys($food);
foreach($keys as $key) {
if($value & $key) $output .= $food[$key].',';
}
print rtrim($output, ',');