Download the PHP package ngekoding/terbilang without Composer
On this page you can find all versions of the php package ngekoding/terbilang. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package terbilang
PHP Terbilang
PHP Terbilang is a library that converts number or currency amount into their Indonesian words representation.
Features
- Converts number values to words in Indonesian.
- Converts currency amounts (in rupiah) to words.
- Supported decimals (comma) for both regular number and currency.
Installation
You can install via composer:
Usage
Basic Usage
This is how to convert a regular number to words:
Then pass the second paramater to true
for currency amount:
Options
You can customize the decimal separator for your conversions:
Note: Will affected only for string input.
Advanced Usage
You can use either numeric or string inputs, but there are some important considerations when dealing with decimals.
For regular numbers, when using numeric input, trailing zeros after the decimal point are not preserved. For example, the number 12345.500
will be presented as 12345.5
.
Especially for currency amounts, two decimal places are always used to adhere to rupiah standards.
To handle the entire input number, including trailing zeros after the decimal point, use string input.
Additionally, with string input, you can easily pass already formatted numbers.
For currency amounts with ,00
decimals, the decimal part will be ignored, as this is the correct format for writing rupiah.
API
Converts a number or currency amount into its Indonesian words representation.
- $number (mixed): The number or currency amount to convert.
- $isCurrency (bool, optional): Whether the conversion is for currency (default: false).
- $decimalSeparator (string, optional): The decimal separator used in the number (default: '.').
References
This library aims to adhere to Indonesian language standards.
Testing
Contributing
Feel free to contribute to improve this library. Fork it, make changes, and submit a pull request.
License
The MIT License (MIT). Please see License File for more information.