tags:

views:

78

answers:

5

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
...
...
+7  A: 

range() supports letters since PHP 4.1, so you can do this:

$azRange = range('A', 'Z');
foreach ($azRange as $letter)
{
  print("$letter\n");
}
therefromhere
A: 

I think you should use the range function:

$a=range("A","Z");
foreach($a as $char)
    echo $char."\n";
mck89
+1  A: 

This:

$range = range("A", "Z");
for ($i=1; i<=100; i++) {
    foreach ($range as $letter) {
      print("$letter$i\n");
    }
}

will print you all the combinations:
A1
B1
C1
... ...
... ...
V100
W100
Z100

Modify the ranges accordingly to your needs.

Dom De Felice
+2  A: 

You can either do:

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

Or:

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

If you're looking for a comprehensive set of Excel functionality, then take a look at PHPExcel which provides a lot of methods for manipulating cell addresses and ranges, as well as reading/writing for Excel and various other spreadsheet file formats

Mark Baker