Many a times, in our applications we need to convert number to text format. Till now, we have to write our own logic for it. But a good news for software developers that PHP has introduced a new class with name “Num2Text” that helps converting a number into respective text value.
How to Convert a Number to Text using PHP
For using this, you just need to get the required PHP class files, include it into your code and just get your purpose fulfilled.
Please go to the Link Below:
And get the fresh copy of the whole code containing the Num2Text class file, along with an example to use it.
You will get it in zipped form that you need to extract to get the code files. Inside the folder you will get two version of Num2Text class:
( this class is used to get the text value of supplied number into most commonly used English language.
( this class is used to get the text value of supplied number into Spanish language)
And here is the example code, showing the use of Num2text classes:
With this class, you can easily get text equivalent of numbers with any number of digits of your choice.
e.g. Lets take the example of a big number
Output: forty-five million, six hundred and forty-five thousand, six hundred and forty-five
Likewise, to get the text format in Spanish language, you just need to include the Spanish counterpart of Num2TextEng class.
Hope, it will ease the developers work a bit. Thanks