Archive June 2011

Finding unique array combinations with PHP (permutations)

Posted by on Jun 23, 2011 in Backend | 4 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.