Converting numbers to letters quickly in PHP

February 27, 2011
Greg Ferrell

For a personal project, I needed to convert numbers to letters and double letters when greater than 26. This is rather a simple thing in PHP using the chr function.

The short of it is that you divide by 26 and get the letter, then repeat the letter for every multiple of 26. This gives us our double letters accurately. I also added an option for uppercase.