VAC-Prabhu VAC-Prabhu - 1 month ago 6
PHP Question

Best way to list Alphabetical(A-Z) using PHP

can any one please let me know, i need to print/list Alphabetical(A-Z) char to manage Excel cells. Is there any php function to list Alphabetic?

I need result as

A1
B1
C1
D1
...
...
...


OR

A
B
C
...
...

Answer

You can either do:

foreach (range('A', 'Z') as $char) {
    echo $char . "\n";
}

Or:

for ($char = 'A'; $char <= 'Z'; $char++) {
    echo $char . "\n";
}