What if I have a multidimensional array, in which I want to make combinations. So for example if I have 3 arrays:
- Array(1,2)
- Array(7,3)
- Array(3,9,8,2)
Then I want a function which make combinations like: array( array(1,7) array(1,3) array( 3,9) etcetera but also array(7,3) array(7,9)
Plus it must check the availability so if the numbers are not available then do not make combinations with them.
Now I got this, and further I cant get:
$xCombinations =
Array(
Array(1,2)
Array(7,3)
Array(3,9,8,2)
);
$available = Array([1] => 2,[2] => 1, [7]=>3,[3]=>4, [8]=>2, [2]=>4);
$combination = Array();
recursiveArray($xCombinations);
function recursiveArray($tmpArr){
if($tmpArr){
foreach ($tmpArr)as $value) {
if (is_array($value)) {
displayArrayRecursively($value);
} else {
//here 1st time $value would be 1,
//so this must now be combined with 7 , 3 , 9, 8 ,2 >
//so you will get an array of array(1,7) array, (1,3) array (3,9)
//etcetera.. there arrays must be also in a multidimensional array
}
}
}
}
3is2? So maximum two occurrences of3per tuple? or per whole set? or what?