PHP - loop through letters

loops, php

Solution

Why don't you make an array of letters and then use nested loops:

$letters = range('A', 'Z');

foreach ($letters as $one) {
  foreach ($letters as $two) {
    foreach ($letters as $three) {
      foreach ($letters as $four) {
        echo "$one$two$three$four";
      }
    }
  }
}

Problem

I am trying to loop through letters rather than numbers. I am trying to do this using chr and the number equivalent but it doesn't seem to be happening! I want four letter loop. So AAAA, AAAB, AAAC etc through to ZZZZ - and yes I know this will likely take a while to execute!

Original source