diff --git a/utilities/format_rupiah/README.md b/utilities/format_rupiah/README.md new file mode 100644 index 0000000..1192393 --- /dev/null +++ b/utilities/format_rupiah/README.md @@ -0,0 +1,12 @@ +# Format Rupiah + +Fungsi ini digunakan untuk mengubah angka (integer) menjadi format string mata uang Rupiah Indonesia. + +## Cara Penggunaan + +```php +require_once 'format_rupiah.php'; + +$harga = 50000; +echo format_rupiah($harga); // Output: Rp 50.000 +``` diff --git a/utilities/format_rupiah/format_rupiah.php b/utilities/format_rupiah/format_rupiah.php new file mode 100644 index 0000000..e109c88 --- /dev/null +++ b/utilities/format_rupiah/format_rupiah.php @@ -0,0 +1,18 @@ + + * @license MIT https://opensource.org/licenses/MIT + * @link https://github.com/bellshade/PHP + */ + +function format_rupiah(int $angka): string +{ + return "Rp " . number_format($angka, 0, ',', '.'); +}