Skip to content

A simple decimal to word converter (Decimal numbers, currency etc.)

Notifications You must be signed in to change notification settings

sakibrahmanchy/decimal-to-words

Repository files navigation

CircleCI GitHub

decimal-to-words

A simple decimal to word converter (Decimal numbers, currency etc.)

Installation

composer require sakibrahamanchy/decimal-to-words

Configurations

Methods

convert($number, $currency_whole = '', $currency_decimal = '', $case = null)

$number - Input number, can be either decimal or ineger, REQUIRED
$currency_whole - Currency Denominator for whole number, Optional, e.g: dollar, taka, rupee etc
$currency_decimal - Currency Denominator for decimal number, Optional, e.g: cents, paisa etc
$case - Case of the output sring, Optional, Can be either 'upper', 'lower' or null

Usage

use SakibRahaman\DecimalToWords\DecimalToWords;

$converted_number = DecimalToWords::convert(0);
var_dump($converted_number);
// Zero

// Basic
$converted_number = DecimalToWords::convert(123.529);
var_dump($converted_number);
// One Hundred Twenty Three Point Fifty Three

// With currency ( 'currency_whole' & 'currency_decimal')
$converted_number = DecimalToWords::convert(42123.529,'dollar',
    'cents');
var_dump($converted_number);
// Forty Two Thousand One Hundred Twenty Three dollar and Fifty Three cents

// With case ('lower' & 'upper')
$converted_number = DecimalToWords::convert(42123.529,'dollar',
    'cents','upper');
var_dump($converted_number);
// FORTY TWO THOUSAND ONE HUNDRED TWENTY THREE DOLLAR AND FIFTY THREE CENTS

About

A simple decimal to word converter (Decimal numbers, currency etc.)

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages