I needed a function, that creates a letter range with arbitrary length.
You specify via the $length parameter, how many entries you need.
Logic is analog to the logic of the column-titles in a calc-sheet.
<?php
/**
* create a letter range with arbitrary length
* @param int $length
* @return array
*/
function createLetterRange($length)
{
$range = array();
$letters = range('A', 'Z');
for($i=0; $i<$length; $i++)
{
$position = $i*26;
foreach($letters as $ii => $letter)
{
$position++;
if($position <= $length)
$range[] = ($position > 26 ? $range[$i-1] : '').$letter;
}
}
return $range;
}
?>