I want to create a character combination for every number from 1-infinity in PHP.
Characters allowed are a-z
I hope you get what I mean. Thank you!
Added all the comments inline.
//Your number
$num = 700;
//Stores the result
$result = "";
$count = 0;
while ($num>=1)
{
/*If we don't do the following line,
26 will be "ba" but not "aa"
As a number 2 can be written as 02 in decimal, but in your example we can't do that, as you won't allow writing 02 as "ac", but simply "c".*/
if ($num < 26) $offset=9; else $offset=10;
//The following part is just a simple base conversion
$remainder = $num%26;
$digit = base_convert($remainder+$offset,10,36);
$result .= $digit;
$num = floor($num/26);
$count++;
}
//Display in reverse order
$result = strrev($result);
echo $result;