Hi!
I have a code that don't do want I want that to do.
<?php
$chars = str_split('abc');
$char_len = count($chars);
$length = 3;
//loop for char_len^length
$loop_length = pow($char_len, $length);
for($i = 0; $i < $loop_length; $i++) {
//convert $a to chars
$string = '';
while($a != 0) {
$string = $chars[$a % $char_len] . $string;
$a = (int) ($a / $char_len);
}
//pad and print string
echo str_pad($string, $length, $chars[0], STR_PAD_LEFT), "<br>\n";
if($loop_length-1 == $i){
$length++;
}
}
?>
And what it do, is to print out all combination of a, b and c. My problem is that when the loop is done (you'll se my if statement) I want to add one on length so it print out a, b and c in four letters. ex abca, abcb. But it isen't working.
Have you any clue that can help me? Thank you for your answer.