0

I have this array : (always an even number of values in array but bigger than 8, half of the array's value is also even);

$array = array("apple", "banana", "pear", "grape", "cherry", "orange", "pineapple", "kiwi");

The result i want :

array(
[0] => array(apple => "banana", pear => "grape", cherry => "orange", pineapple => "kiwi"),
[1] => array(grape => "apple", banana => "pear", orange => "pineapple", kiwi => "cherry"),
...etc
[7] => array(banana => "apple", grape => "pear", orange => "cherry", kiwi => "pineapple"),
[8] => array(apple => "grape", pear => "banana", pineapple => "orange", cherry => "kiwi"), 
...etc until [13]
)

As you can see, each value is sometimes a key and sometimes a value, all possible combinations must be made except the same values ( apple with apple must not meet ).

if the first encounter [0] "apple" is a key, in the next encounter [1] it should be a value

The same two values ( apple and banana ) cannot meet again until the ending half of the array.

Anyone can help me out with this ?

Rares Hideg
  • 394
  • 3
  • 11
  • i only found part of the problem there, the part that i am most interested is `if the first encounter [0] "apple" is a key, in the next encounter [1] it should be a value The same two values ( apple and banana ) cannot meet again until the ending half of the array.` – Rares Hideg Oct 03 '13 at 21:32
  • I think you can have 64 possible combinations. – StackSlave Oct 03 '13 at 21:33
  • Actually no, because in the same array result value where apple meets banana, other keys also meet, counting all of the keys+values combinations yes, there could be 64-8 or 64 if apple would meet apple, but counting only the main array keys , the result should contain 14 keys, now that i say that i noticed I've wrote 15. it should go from 0 to 13. – Rares Hideg Oct 03 '13 at 21:43

1 Answers1

0

I have found my answer thanks to google.

The most appropriate reference to my question is sports team fixtures. Searching that on google found me the answer.

Rares Hideg
  • 394
  • 3
  • 11