Assume you have a set of items in an array.
A, B, C, D, E, F, G, H
Using PHP, how would you randomly pair the letters together without pairing them with a duplicate of themselves?
Such as this:
A->pairedLetter = G
B->pairedLetter = C
C->pairedLetter = E
D->pairedLetter = A
E->pairedLetter = B
F->pairedLetter = D
G->pairedLetter = F
and so on...
EDIT:
Oh, and also, If A is paired with F, F can NOT be paired with A.
So there will have to be as many relationships as there are items.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…