I'm working out an algorithm to get permutations like
123
132
213
231
312
321
I'm doing it using nested foreach loops.
for (..) {
for(..) {
for(..) {
echo $i . $j . $k . "<br />";
}
}
}
Problem is those # of nested loops are optimized for 3-spot permutations. How can I could I dynamically set the number of nested for loops to generate 4-letter or 5-letter permutations?