1 => "first" or "one" in PHP?
Written By alexsuraci on May. 31, 2008.
3 Comments
Report Note
+ Clip This
Does anyone know a way to convert a number to its text form without using an infinitely long array? I've looked high and low and can't find a single thing in Google. It seems like it'd be pretty difficult to make a trustworthy algorithm for.

alexsuraci
Written May. 31, 2008 / Report /
(I can't seem to edit notes. Responses are fine, but not the first note.)
The reason I'm asking is to use it for CSS classes. Although, I could probably just use "num1", "num2", and so on. Still interested in a response to this though.
Oli
Written Jun. 1, 2008 / Report /
An infinite array would be thoroughly unnecessary as numerical nomenclature does adhere to programmable rules.
Googling "convert number to word php" will show you the way. Knock off the php for some JS methods of doing it.
alexsuraci
Written Jun. 1, 2008 / Report /
A couple people pointed me here and here. I've since gone with num1, num2, etc., for the sake of simplicity, but there're the solutions.
Oli: That "infinite array" wasn't a serious suggestion. ;)