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 ?