"Steen Rabol" <[EMAIL PROTECTED]> wrote in message 000501c1fe7d$e8c7f470$[EMAIL PROTECTED]">news:000501c1fe7d$e8c7f470$[EMAIL PROTECTED]... > Hi > > I have 6 arrays with data and would like to have all possible > combinations > Eg. > > $a1 = array(1,2); > $a2 = array(3,4); > $a3 = array(5,6); > $a4 = array(7,8); > $a5 = array(9,10); > $a6 = array(11,12); > > the result should then be a new array like this: > > [0] = 1,3,5,7,9,11 > [1] = 1,4,5,7,9,11 > [2] = 1,6,5,7,9,11
I'm not sure I follow here... you want all possible combinations of one value from each array? ie one of (1,2) and one of (3,4) and one of (5,6) etc (64 combinations), or all combinations of 6 values from anywhere - six of (1,2, 3,4,5,6,...) (924 combinations)? I would assume the first except for [2]. The solution depends heavily on this question. Also, rather than 'returning all possible combinations' I would really strongly suggest testing each combination as it is generated, and only keep candidates which match whatever criteria you are looking for, ie "combinations which sum to a multiple of 3" or whatever. ... in fact, if you tell us more about what problem you are trying to solve by generating combinations, we might be able to suggest a better way of going about it. -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php