number-to-words icon indicating copy to clipboard operation
number-to-words copied to clipboard

how to force writing zero fraction

Open naja7host opened this issue 6 years ago • 3 comments

how to force write zero fraction, so if i have 144.00 USD i get the fallowing

$currencyTransformer->toWords(14400, 'USD'); one hundred forty-four dollar.

i want to get one hundred forty-four dollar and zero cent .

naja7host avatar Jan 22 '19 01:01 naja7host

You can't at the moment. Feel free to add the missing functionality. Thanks!

kwn avatar Jan 29 '19 20:01 kwn

I can be wrong, but it seems to me that this functionality already exists (see #79 PR). I studied the code and added documentation.

PS: Immediately I apologize if something in the description is written incorrectly. I know English very poorly, so I translate Google Translate. ¯_(ツ)_/¯

andrey-helldar avatar Jul 05 '19 21:07 andrey-helldar

is not working, or maybe i have missed something

$CurrencyTransformerOptions = new CurrencyTransformerOptions(); $CurrencyTransformerOptions->setConvertFractionIfZero(true); $CurrencyTransformerOptions->setShowDecimalIfZero(true); $numberToWords = new NumberToWords(); $currencyTransformer = $numberToWords->getCurrencyTransformer('en'); $text = $currencyTransformer->toWords(26400, 'USD', $CurrencyTransformerOptions);

output

two hundred sixty-four dollars

naja7host avatar Jul 16 '19 15:07 naja7host