PHP: Express Number in Words

anita.kcx picture anita.kcx · Jul 16, 2012 · Viewed 94.3k times · Source

Is there a function that will express any given number in words?

For example:

If a number is 1432, then this function will return "One thousand four hundred and thirty two".

Answer

martindilling picture martindilling · Oct 29, 2014

Use the NumberFormatter class that are in php ;)

$f = new NumberFormatter("en", NumberFormatter::SPELLOUT);
echo $f->format(1432);

That would output "one thousand four hundred thirty-two"