Skip to content
Advertisement

Converting a number (1, 2, 3) to a string (one, two, three) in PHP

Does anyone know how to convert a number such as 1, 2, or 3 to their text version (one, two, three) in PHP? I only need to convert from 1 to 99. I know I could write a huge switch statement but that would be ridiculous.

Advertisement

Answer

pear has a package Numbers_Words:

$numberToWord = new Numbers_Words();
echo $numberToWords->toWords(200);
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement