1

This is just kind of a question out of curiosity. Is there a PHP function at this point that converts a number into the textual equivalent? For example 1 = 'one'. 1000 = 'one-thousand'.

I don't think this would really be all that hard to make. Generally the way we speak our numbers is pretty consistant except for the first 20 numbers. I haven't been able to find a function like that though.

I might end up making one though. Could be kind of a fun simple-AI project.

  • This has definitely been asked here before. Just gotta find it. – John Conde Mar 17 '13 at 19:53
  • Hha I was afriad. I tried looking, couldn't find anything. –  Mar 17 '13 at 19:53
  • You should see: http://www.karlrixon.co.uk/writing/convert-numbers-to-words-with-php/ – Emanuil Rusev Mar 17 '13 at 19:55
  • http://stackoverflow.com/questions/2951432/php-print-integer-in-words, http://stackoverflow.com/questions/2112571/converting-a-number-1-2-3-to-a-string-one-two-three-in-php – fsw Mar 17 '13 at 19:57

1 Answers1

4

With intl/NumberFormatter:

var_dump(
    numfmt_create('en_US', NumberFormatter::SPELLOUT)->format(655)
);
julp
  • 3,860
  • 1
  • 22
  • 21