Jump to content

[SOLVED] looping through letters


perezf

Recommended Posts

You can try:

<?php
$letters = range('a', 'z');
for ($first=0;$first<count($letters);$first++){ 
      $firstletter = $letters[$first];
              for ($second=0;$second<count($letters);$second++){
                        $secondletter = $letters[$second];
                                 for ($third=0;$third<count($letters);$third++) {
                                         $thirdletter = $letters[$third];
                                         echo $firstletter . $secondletter . $thirdletter . "<br />";
                                 }
               }
}
?>

 

That's what I thought up in about 30 seconds.  I mean I could probably right some recursive function that just makes a large array that you can loop through, but I'm kind of in a non-thinking state at the moment.  Btw, I just tested that code and it works. xD

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.