In PHP, is there an easy way to convert a number to a word? For instance, 27 to twenty-seven.
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
Very simple way to convert number to words using PHP function.
I rewrote the code above to fit the standard U.S. written word number format.
Using NumberFormatter class it is simple to get convert to words.
Yes there is. without using a library you just need to follow this..
First you need to check in your server if
;extension=php_intl.dll
is enabled in your php.ini if still not work you need to see this answer.intl extension php_intl.dll with wamp
after successfully moving all the files starts with icu.
from:
<wamp_installation_path>/bin/php/php5.4.3/
to:
<wamp_installation_path>/bin/apache/apache2.2.22/bin/
and restart your server.
try to run this code:
it will show the output of one hundred twenty-three thousand four hundred fifty-six.
hope that helps everyone :).
You can use the NumberFormatter Class:
There is the
Numbers_Words
package in PECL. It does exactly what you ask for. The following languages are supported: