3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function base26($value) { $name = ''; for ($exponent = 0; pow(26, $exponent) <= $value; $exponent++) { $digitValue = intval(pow(26, $exponent)); $remainder = $value % intval(pow(26, $exponent + 1)); $ascii = 64 + intval($remainder / $digitValue); $name = chr($ascii) . $name; $value -= $remainder; } return $name; } for ($i = 1; $i < 28; $i++) { echo $i . "->" . base26($i) . "\n"; }
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
1->A 2->B 3->C 4->D 5->E 6->F 7->G 8->H 9->I 10->J 11->K 12->L 13->M 14->N 15->O 16->P 17->Q 18->R 19->S 20->T 21->U 22->V 23->W 24->X 25->Y 26->A@ 27->AA