Hello,
I have this piece of code that works as intended:
$chars = array('1','2','3');
$cnt = count($chars);
$strings = array();
for ($f = 0; $f < $cnt; $f++) {
for ($s = 0; $s < $cnt; $s++) {
for ($t= 0; $t < $cnt; $t++) {
$strings[] = $chars[$f] . $chars[$s] . $chars[$t];
}
}
}
print_r($strings);
The problem i'm facing is that i want to transform it in a function where i pass the chars and the nr of elements in the permutation in the above code if i want more elements ill duplicate the for loop and so on.
For example i'm trying to create a function like:
function perm($chars,$nrElements){
}
thank you in advance