LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Textual representation of numbers (https://www.linuxquestions.org/questions/programming-9/textual-representation-of-numbers-225263/)

lackluster 09-01-2004 10:03 AM

Textual representation of numbers
 
I'm sure somebody somewhere must have asked this, but I cannot for the life of me find this information anywhere online. Perhaps I'm just searching wrong. Anyways, I was wondering if anyone had or knew of a function, preferably in PHP, that would give back a numerical representation of a number. Something like:

Code:

<?php
$number = 12;
$text = textual_representation($number);
print $text;
?>

Would give something like "Twelve".

I'm sure this wouldn't be too terribly difficult to invent, but if it's already there, that would be great.

scissors 09-01-2004 10:39 AM

I don't know about doing it in php, but you can in perl, using the Number::Spell module.

lackluster 09-01-2004 10:56 AM

That should be easy enough to convert. Thanks!

lackluster 09-05-2004 03:05 PM

I barely modified it. This was the easiest conversion ever. It took less than 30 minutes (I did, being the american scum that I am, leave out the european formatting): http://lackluster.tzo.com:1024/NumberSpell.php.txt

Proud 09-05-2004 04:02 PM

Cool. Could you submit it to a more perminant place on the web, or to the PHP developers maybe? :)


All times are GMT -5. The time now is 08:49 PM.