I have a list of permissions arranged in an array, for example:
$permissions = array(true, true, false, false, true, ...);
My intention is to convert the array to a chain of 1's and 0's:
$pseudo_binary = array_to_binary($permissions); //011001000110111101100111
And then consider that string as a binary number and stored in the database as an ASCII word:
$ascii = binary_to_word($pseudo_binary); //dog
The array-to-binary() method is not important, I use a simple foreach. But I ask for help to do these conversions:
(string)'011001000110111101100111' -----> 'dog'
'dog' -------> (string)'011001000110111101100111'