Forward unique combinations in multiple array

Create combinations in existing series with next coming series in a multiple array. For the first row in the array all values will be matched against all values in the next coming row, to be able to do some calculation or create a unique combination of values.

<?php
$cols
[] = array(1,2,3);
$cols[] = array(4,5,6);
$cols[] = array(7,8,9);

foreach (
$cols as $key => $col) {
    foreach (
$col as $key1 => $value1) {
        foreach (
$col[$key+1] as $key2 => $value2) {
                    echo
"<br>$value1 => $value2";
        }
    }
}
?>

will give:

1 => 4

1 => 5

1 => 6

2 => 4

2 => 5

2 => 6

3 => 4

3 => 5

3 => 6

4 => 7

4 => 8

4 => 9

5 => 7

5 => 8

5 => 9

6 => 7

6 => 8

6 => 9

Knowledge keywords: