3
I am creating a function that returns the alphabet to me in an array according to the size of columns passed.
At first I was only making a loop using the range("A", "Z"); but when I had more than 26 columns no longer attended me, with this, searching the internet, what I found was a suggestion here http://forum.imasters.com.br/topic/532733-repetir-o-alfabeto-varias-vezes-como-as-colunas-do-excel/ given by the reply of Willian Bruno, but that is also not very correct, at least it did not work here, dai using as a base I created mine only that also does not return me the expected, that would be the alphabet (a-z, aa-zz, aaa-zzz), similar to the columns of excel.
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;
}
						
If the
$columnSizefor 5 it must go fromauntile? if it is 27 ofaup toaa?– rray
If it’s 1 to 52 then it has to be
auntilaz. if it is 1 to 53 then it has to beauntil 53baand so on– Marcelo Diniz