Answer the question
In order to leave comments, you need to log in
Recursive function to iterate over combinations of an array?
How to write a recursive function for the below code?
$arr = array('a', 'b', 'c');
$lim = count($arr);
for($i1 = 0; $i1 < $lim; $i1++) {
for($i2 = 0; $i2 < $lim; $i2++) {
for($i3 = 0; $i3 < $lim; $i3++) {
echo $arr[$i1].$arr[$i2].$arr[$i3].'<br>';
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question