I have defined the multidimensional array $binary
:
$binary = [[0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1]];
I want to create a function to display binary numbers from this array.
count($binary)
should determine the amount of digits in the number, in this case 6.
My goal is for the function to display all possible variations of a (in this case six digit) binary number:
100000, 110000, 101000, 1001000 etc.
The only idea that I have is to create a series of foreach loops that are nested in each other:
foreach ($binary[0] as $digit) {
foreach ($binary[1] as $digit) {
etc.
}
}
however the amount of arrays inside $binary might increase, as a result you'd have to adjust it manually which is not what I'm looking for.
Does anyone know how to program such a function?