hi,
i want permutation for all alphabets with word length is 8.but i get only permutation for 4.pls help me to debug this issue

code:

<?PHP

FUNCTION permutations($letters,$num){ 
$last = STR_REPEAT($letters{0},$num); 
$result = ARRAY(); 
WHILE($last != STR_REPEAT(lastchar($letters),$num)){ 
echo "$last";
$result[] = $last; 
$last = char_add($letters,$last,$num-1); 
} 
$result[] = $last; 
RETURN $result; 
} 
FUNCTION char_add($digits,$string,$char){ 
IF($string{$char} <> lastchar($digits)){ 
$string{$char} = $digits{STRPOS($digits,$string{$char})+1}; 
RETURN $string; 
}ELSE{ 
$string = changeall($string,$digits{0},$char); 
RETURN char_add($digits,$string,$char-1); 
} 
} 
FUNCTION lastchar($string){ 
RETURN $string{STRLEN($string)-1}; 
} 
FUNCTION changeall($string,$char,$start = 0,$end = 0){ 
IF($end == 0) $end = STRLEN($string)-1; 
FOR($i=$start;$i<=$end;$i++){ 
$string{$i} = $char; 
} 
RETURN $string; 
} 
?> 




<?php
for($j=1;$j<9;$j++){
$Array=permutations("ABCDEFGHIJKLMNOPQRSTUVWXYZ",$j); 
FOR($i=0 ; $i < COUNT($Array) ; $i++) { 
ECHO "$i." . $Array[$i] . "<BR>"; 
} 
}
?> 

output:

i want a output like this
a
b
c
d
e
f
.
.
.
.
.
z
aa
ab
ac
ad
.
.
.
.
.
.
az
.
.
.
.
.
.
.
.
.
.
zzzzzzzz

But the above code shown like this
a
b
c
d
.
.
.
.
.
aa
ab
ac
.
.
.
.
az
.
.
.
zzzz

yes

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.