-5

Is it possible to convert an integer to a written out word? IE, convert '29' to 'twentynine'?

There is a comment on the strval() page of the PHP Manual, but it's from 13 years ago, before PHP 5 was introduced. Is there a standard PHP function that can do the same, or maybe an easier way to write out the function?

https://secure.php.net/manual/en/function.strval.php

Sander
  • 1
  • 3
  • The solution is in the comments of the page you posted yourself. – berend Jul 06 '17 at 12:57
  • The [first comment](https://php.net/manual/en/function.strval.php#41988) on the page you linked has the answer – crazyloonybin Jul 06 '17 at 12:58
  • 2
    No, there is no build-in function for this. In English this is still rather trivial; other languages can be much harder. And you got a solution already - so either take that as-is, or make the effort to understand what it does yourself so that you can try and find a “shorter” solution if you like. – CBroe Jul 06 '17 at 12:58
  • The strval() is used to convert a value of a variable to a string, and nothing more. – David Jul 06 '17 at 12:59
  • Am I being downvoted for (correctly) thinking a 13 year old comment is outdated, and been replaced with a standard function? Couldn't find that duplicate, thanks for pointing it out. – Sander Jul 06 '17 at 13:59

1 Answers1

1

Please, use this: http://dk2.php.net/manual/en/class.numberformatter.php

Example:

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

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

Pv-Viana
  • 632
  • 7
  • 25