1. Go to this page and download the library: Download lubosdz/number-to-words library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lubosdz / number-to-words example snippets
// use either factory ..
use lubosdz\numberToWords\NumberToWords;
// .. or language specific implementation
use lubosdz\numberToWords\NumberToWords_SK;
use lubosdz\numberToWords\NumberToWords_CZ;
use lubosdz\numberToWords\NumberToWords_EN;
// Slovensky / Slovak
NumberToWords::convert(123.45, 'sk'); // jednostodvadsaťtri celé štyridsaťpäť
NumberToWords_SK::convert(123.45); // jednostodvadsaťtri celé štyridsaťpäť
NumberToWords_SK::convertIntl(123.45); // jednasto dvasaťtri čiarka štyri päť (ICU returns "dvasať", bug)
// supply number as string - will retain right-sided zeroes on decimal part
NumberToWords_SK::convert(37.40); // tridsaťsedem celé štyri - strip off right-sided zeroes
NumberToWords_SK::convert("37.40"); // tridsaťsedem celé štyridsať - keep right-sided zeroes
NumberToWords_SK::convert("37.400"); // tridsaťsedem celé štyristo - keep right-sided zeroes
// arbitrary decimals word separator
NumberToWords_EN::$txtDecimal = " čiarka ";
NumberToWords_EN::convert(12.30); // dvanásť čiarka tridsať
// with decimals as a fraction - useful in accounting
NumberToWords::$decimalsAsFraction = true;
NumberToWords::convert(123.45, 'sk'); // jednostodvadsaťtri (45/100)
// enforce desired number of decimals
NumberToWords::$numberOfdecimals = 2;
NumberToWords::convert(12.3, 'sk'); // dvanásť celé tridsať
// Česky / Czech:
NumberToWords::convert(123.45, 'cz'); // allowed cz or cs, // sto dvacet tři celá čtyřicet pět
NumberToWords_CZ::convert(123.45); // sto dvacet tři celá čtyřicet pět
NumberToWords_CZ::convertIntl(123.45); // sto dvacet tři celá čtyři pět
// English:
NumberToWords::convert(123.45); // lang code not needed since english is default
NumberToWords_EN::convert(123.45); // one hundred twenty-three point fourty-five
NumberToWords_EN::convertIntl(123.45); // one hundred twenty-three point four five
// arbitrary decimals word separator
NumberToWords_EN::$txtDecimal = " comma ";
NumberToWords_EN::convert(12.30); // twelve comma thirty
// really big number:
NumberToWords_EN::convert(987654321.123);
// nine hundred eighty-seven million, six hundred fifty-four thousand, three hundred twenty-one point one hundred twenty-three
NumberToWords_EN::convertIntl(987654321.123);
// nine hundred eighty-seven million six hundred fifty-four thousand three hundred twenty-one point one two three
// Russian:
NumberToWords::convert(123.45, 'ru'); // сто двадцать три целых сорок пять сотых
// German:
NumberToWords::convert(123.45, 'de'); // einhundertdreiundzwanzig Komma vier fünf
// French:
NumberToWords::convert(123.45, 'fr'); // cent vingt-trois virgule quatre cinq
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.