Last active
July 16, 2020 07:00
-
-
Save nurrachmat-nr/74f565fc83781c4c41ec0600db1dd73d to your computer and use it in GitHub Desktop.
Fungsi untuk membuat nominal terbilang dalam rupiah (Max. dalam Juta)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @package njr_helper | |
* @subpackage Helper | |
* @author Nur Rachmat <rachmat.nur91@gmail.com> | |
* @version 0.1 | |
* @copyright Copyright © 2017 Nur Rachmat <rachmat.nur91@gmail.com> | |
*/ | |
public function terbilang($satuan) | |
{ | |
$huruf = array ("", "Satu", "Dua", "Tiga", "Empat", "Lima", "Enam", "Tujuh", "Delapan", "Sembilan", "Sepuluh","Sebelas"); | |
if ($satuan < 12) | |
return " ".$huruf[$satuan]; | |
elseif ($satuan < 20) | |
return $this->Terbilang($satuan - 10)." Belas"; | |
elseif ($satuan < 100) | |
return $this->Terbilang($satuan / 10)." Puluh".$this->Terbilang($satuan % 10); | |
elseif ($satuan < 200) | |
return "Seratus".$this->Terbilang($satuan - 100); | |
elseif ($satuan < 1000) | |
return $this->Terbilang($satuan / 100)." Ratus".$this->Terbilang($satuan % 100); | |
elseif ($satuan < 2000) | |
return "Seribu".$this->Terbilang($satuan - 1000); | |
elseif ($satuan < 1000000) | |
return $this->Terbilang($satuan / 1000)." Ribu".$this->Terbilang($satuan % 1000); | |
elseif ($satuan < 1000000000) | |
return $this->Terbilang($satuan / 1000000)." Juta".$this->Terbilang($satuan % 1000000); | |
elseif ($satuan >= 1000000000) | |
return "Angka terlalu Besar"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment