I looked around but I couldn't find anything that suited for this.
$n = 3;//number of events
$k = array(0,1);//possible outcomes
I'd like to have an array containing all the possible outcomes:
$result = array([0] => array(0,0,0), [1] => array(1,0,0)... [7] =>array(1,1,1));
I tried this long and static method that leads me to nothing useful:
for($a=0;$a<count($k);$a++) {
for($b=0;$b<count($k);$b++) {
for($c=0;$c<count($k);$c++) {
$push = array($a,$b,$c);
array_push($result,$push);
}}}
How can I re-write this to get a function that takes the n value into account? So if I change the value of $n to 4 I get an array like:
$result = array([0] => array(0,0,0,0), [1] => array(1,0,0,0)... [15] =>array(1,1,1,1));