Forum Moderators: coopster

Message Too Old, No Replies

Need A Combination Function

         

BlackRaven

8:38 pm on Aug 24, 2006 (gmt 0)

10+ Year Member



Could some one help in creating a combination function, basically i need a function that spits out ever combination of a list i have got. So say the list i got has three items i need something will Output ever combination in three items:

Item 1 Vs Item 2
Item 1 Vs Item 3
Item 2 Vs Item 1
Item 2 Vs Item 3
Item 3 Vs Item 1
Item 3 Vs Item 2

jatar_k

8:41 pm on Aug 24, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



wouldn't 1vs2 and 2vs1 be the same thing?

jatar_k

8:47 pm on Aug 24, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



be that as it may you can make changes to this if you need to

<? 
$mystuff = array('item1','item2','item3');
$mylimit = count($mystuff);
$counter = 0;
while ($counter < $mylimit) {
$intcount = 0;
while ($intcount < $mylimit) {
if ($intcount!= $counter) echo '<br>',$mystuff[$counter],' VS ',$mystuff[$intcount];
$intcount++;
}
$counter++;
}
?>

BlackRaven

11:28 pm on Aug 24, 2006 (gmt 0)

10+ Year Member



thanks jatar

[edited by: BlackRaven at 11:29 pm (utc) on Aug. 24, 2006]