Here is a small, but useful, function in PHP to convert numbers to alphabetic characters. So, 1 would return an A, a 4 will return a D, a 27 will return an AA, and so on. I find this function useful if you want to create a list of letters for an index or some sort. Anyways, here is the PHP code with an example on how to use it.


<?php

function numtoalpha($number) { // function

  $anum = "";

  while($number >= 1) {

    $number = $number - 1;

    $anum = chr(($number % 26)+65).$anum;

    $number = $number / 26;

  }

  return $anum;

}


// example:

for ($x=0,$z=0;0<=26;$x++) {

  $convert = numtoalpha($z++);

  echo($convert." ");

}

?>

The example above should have printed the complete alphabet in uppercase a space apart.