Forum > Computers, Web and Software Development

Converting Numbers into their Word Equivalent

(1/1)

osofem:
Introduction
I am currently working on a forum site which surely has numbers in various places representing different things. Being a slightly tidy guy , I strive to make the numbers look trimmed by formatting them with number_format ("putting the integers into comma"). But taking a step further, I decided to add a mouse-over effect to spell out the numbers (i.e., when you point on "12, 345 user online" the title attribute reads "Twelve Thousand, Three Hundred and Forty Five users online"). What I came up with can convert any positive integer up to (1x1064)-1 to it word equivalent though the number has to be entered as a string if it is greater than PHP_INT_MAX to prevent PHP from exponenting it (i.e. changing 2000 to 2e3).

Continue here on Codeproject

Navigation

[0] Message Index

Go to full version