iterations

Finding unique array combinations with PHP (permutations)

Posted by Danny Herran on Jun 23, 2011 in Backend | 6 comments

I was developing a website where people would place horse bets and the system should be able to calculate all the possible permutations based on the user selection. That means: finding all the possible combinations in a two dimensional array. I found a couple of functions but none of them would keep the array keys intact. So, I came up with this idea after a few gray hairs.