Skip to content

qadrLabs/php-rupiah

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-rupiah

A lightweight PHP 8.3+ library to format and parse Indonesian Rupiah (IDR) currency values. Zero external dependencies.

Installation

composer require qadrlabs/php-rupiah

Usage

use QadrLabs\Rupiah\Rupiah; use QadrLabs\Rupiah\RupiahStyle;

// Standard Rp prefix (default) Rupiah::format(1500000); // "Rp 1.500.000"

// ISO currency code Rupiah::format(1500000, RupiahStyle::ISO); // "IDR 1.500.000"

// No prefix, useful for tables or custom rendering Rupiah::format(1500000, RupiahStyle::Plain); // "1.500.000"

// Float values are rounded to the nearest integer Rupiah::format(99999.5); // "Rp 100.000"

// Parse any of the above formats back to an integer Rupiah::parse('Rp 1.500.000'); // 1500000 Rupiah::parse('IDR 1.500.000'); // 1500000 Rupiah::parse('1.500.000'); // 1500000

Testing

composer test

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages