These are chat archives for JanGalek/netteSocials

6th
Oct 2016
Jan Galek
@JanGalek
Oct 06 2016 17:58

<?php
function workOutCombinations ($data, &$all = array(), $group = array(), $val = null, $i = 0) {
if (isset($val)) {
array_push($group, $val);
}

if ($i >= count($data)) {
    array_push($all, $group);
} else {
    foreach ($data[$i] as $v) {
        workOutCombinations($data, $all, $group, $v, $i + 1);
    }
}
return $all;

}

$ar0 = array('a', 'b', 'c');
$ar[1] = array('1', '2', '3');
$ar[2] = array('red', 'green', 'blue');
$ar[2] = array('cat', 'dog', 'fish');

$combos = workOutCombinations($ar);
print_r($combos);

$array = [
0 => [
1 => 'value',
2 => 'value',
],
1 => [
3 => 'value',
4 => 'value',
],
];