fork download
  1. <?php
  2.  
  3. function numberToColumnName($number){
  4. $abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  5. $abc_len = strlen($abc);
  6.  
  7. $result = "";
  8. $tmp = $number;
  9.  
  10. while($number > $abc_len) {
  11. $remainder = $number % $abc_len;
  12. $result = $abc[$remainder-1].$result;
  13. $number = floor($number / $abc_len);
  14. }
  15. return $abc[$number-1].$result;
  16. }
  17.  
  18. for($i = 0; $i < 50; $i++){
  19. echo numberToColumnName($i)."\n";
  20. }
Success #stdin #stdout #stderr 0.02s 52432KB
stdin
Standard input is empty
stdout
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
AA
AB
AC
AD
AE
AF
AG
AH
AI
AJ
AK
AL
AM
AN
AO
AP
AQ
AR
AS
AT
AU
AV
AW
stderr
PHP Notice:  Uninitialized string offset: -1 in /home/RKZ7sS/prog.php on line 15
PHP Notice:  String offset cast occurred in /home/RKZ7sS/prog.php on line 15
PHP Notice:  String offset cast occurred in /home/RKZ7sS/prog.php on line 15
PHP Notice:  String offset cast occurred in /home/RKZ7sS/prog.php on line 15
PHP Notice:  String offset cast occurred in /home/RKZ7sS/prog.php on line 15
PHP Notice:  String offset cast occurred in /home/RKZ7sS/prog.php on line 15
PHP Notice:  String offset cast occurred in /home/RKZ7sS/prog.php on line 15
PHP Notice:  String offset cast occurred in /home/RKZ7sS/prog.php on line 15
PHP Notice:  String offset cast occurred in /home/RKZ7sS/prog.php on line 15
PHP Notice:  String offset cast occurred in /home/RKZ7sS/prog.php on line 15
PHP Notice:  String offset cast occurred in /home/RKZ7sS/prog.php on line 15
PHP Notice:  String offset cast occurred in /home/RKZ7sS/prog.php on line 15
PHP Notice:  String offset cast occurred in /home/RKZ7sS/prog.php on line 15
PHP Notice:  String offset cast occurred in /home/RKZ7sS/prog.php on line 15
PHP Notice:  String offset cast occurred in /home/RKZ7sS/prog.php on line 15
PHP Notice:  String offset cast occurred in /home/RKZ7sS/prog.php on line 15
PHP Notice:  String offset cast occurred in /home/RKZ7sS/prog.php on line 15
PHP Notice:  String offset cast occurred in /home/RKZ7sS/prog.php on line 15
PHP Notice:  String offset cast occurred in /home/RKZ7sS/prog.php on line 15
PHP Notice:  String offset cast occurred in /home/RKZ7sS/prog.php on line 15
PHP Notice:  String offset cast occurred in /home/RKZ7sS/prog.php on line 15
PHP Notice:  String offset cast occurred in /home/RKZ7sS/prog.php on line 15
PHP Notice:  String offset cast occurred in /home/RKZ7sS/prog.php on line 15
PHP Notice:  String offset cast occurred in /home/RKZ7sS/prog.php on line 15