I'm creating a function that returns the alphabet in an array according to the size of passed columns.
At first I was only looping using the range ("A", "Z"); but when I had more than 26 columns I did not answer any more, what I found was a suggestion here link given by the answer from Willian Bruno, but that is also not very correct, at least it did not work here, hence using as a basis I created mine alone that also does not return the expected, which would be the alphabet (az, aa -zz, aaa-zzz), similar to the excel columns.
Follow what I'm doing.
function alphaRepeat($columnsSize = 10)
{
$i = 0;
$j = 0;
$abc = range("A", "Z");
$abcSize = count($abc);
$alpha = array();
while ($i < $columnsSize) {
if (((int)($i / $abcSize) - $j) > 0) {
$j++;
}
$item = '';
if ($j > 0) {
$item.= str_repeat($abc[$j - 1], $j);
}
$item.= $abc[$i - ($abcSize * $j)];
$alpha[] = $item;
$i++;
}
return $alpha;
}