Generate a list with letters of the alphabet, in PHP or JavaScript [closed]

0

I want to generate a list that carries an index with letters, for example: A.- list B.- list C.- list .... but if the list passes the letter Z that generates like this: AA.- list AB.- list AC.- list

I hope you can support me ... Greetings !!!!

    
asked by Jesus Rolando 31.07.2017 в 20:45
source

2 answers

2

This works simple and simple using recursion

function getExcelCol($num) {
    $numero = $num % 26;
    $letra = chr(65 + $numero);
    $num2 = intval($num / 26);
    if ($num2 > 0) {
        return getExcelCol($num2 - 1) . $letra;
    } else {
        return $letra;
    }
}
    
answered by 31.07.2017 в 21:11
0

you do not have to worry about this anymore, PHP does what you want it to do

    <?php
        $miletra = "A";
        for ($i =0; $i < 30; $i++){
            echo $miletra."<br/>";
            $miletra++;
        }
?>
    
answered by 31.07.2017 в 20:54