after working almost an entire day my brain got stuck in my own thought about how to fix this problem. One example.
- 1,
- x,
- 2,
- 1x,
- 1,
- 2,
- x,
- 1,
- 2,
- 1,
- x,
- x,
- 1..
That's one coupon, I want it to be sorted after the possibilities of the combinations let's say this coupon has 2 possibilities those are: 1x2112x121xx1, 1x2x12x121xx1.. the fourth match is the one that's different..
So... my question is how should this be done programmatly.
I get the data from a database and it looks like this.
array(
"gameNumber" => "1",
"bets" => array(
[0] => "1"
),
"gameNumber" => "2",
"bets" => array(
[0] = "x"
),
"gameNumber" => "3",
"bets" => array(
[0] = "2"
),
"gameNumber" => "4",
"bets" => array(
[0] = "1",
[1] = "x"
)
);
I'm not sure that will help you but that's how it looks.
I've got it all into a recursed array with help of the last answer of this: How to build recursive function to list all combinations of a multi-level array?.
So my new recursion function looks like this:
public function _combine_bets($array)
{
$cur = array_shift($array);
$result = array();
if(!count($array)) {
foreach($cur['bets'] as $option) {
$result[] = $cur['matchNumber']."-".$option;
}
return $result;
}
foreach($cur['bets'] as $bet) {
$result[$cur['matchNumber'].'-'.$bet] = $this->_combine_bets($array);
}
return $result;
}
This way I got this array as a result: http://pastie.org/5692408
Soo..... back to my question I want to make this look like only the value of the bet.. let's say it should look like this: 1x2112x121xx1, 1x2x12x121xx1. instead of a big array. I need to make this for all possibilites this is a coupon on just 2 different possibilities, but.. it can be alot more.
a user can choice 1,x,2,1x,12,x2,1x2 on a match I meant that's all options a user has on 13 different games,
if you need more information just tell me and I will update this..