Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,933 questions

51,870 answers

573 users

How to create a list of four-letter all combinations in PHP

1 Answer

0 votes
function four_letters_combination()
{
    $s = "abcdefghijklmnopqrstuvwxyz";
   
    $s_size = strlen($s);
    for ($i = 0; $i < $s_size; $i++)
    {
        for ($j = 0; $j < $s_size; $j++)
        {
            for ($k = 0; $k < $s_size; $k++)
            {
                for ($m = 0; $m < $s_size; $m++)
                {
                    echo $s[$i] . $s[$j] . $s[$k] . $s[$m] . " ";
                }
            }
        }
        echo "<br />";
    }
}       

four_letters_combination(); 


 
/*
run: 

aaaa aaab aaac aaad aaae aaaf aaag aaah aaai aaaj aaak aaal aaam aaan aaao aaap aaaq aaar ...
aaaz aaba aabb aabc aabd aabe aabf aabg aabh aabi aabj aabk aabl aabm aabn aabo aabp aabq ...
aaby aabz ...

...

zzxw zzxx zzxy zzxz zzya zzyb zzyc zzyd zzye zzyf zzyg zzyh zzyi zzyj zzyk zzyl zzym zzyn ...
zzyv zzyw zzyx zzyy zzyz zzza zzzb zzzc zzzd zzze zzzf zzzg zzzh zzzi zzzj zzzk zzzl zzzm ... 
zzzu zzzv zzzw zzzx zzzy zzzz 

*/

 



answered May 31, 2017 by avibootz
edited May 31, 2017 by avibootz
...