Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function penyebut($nilai)
- {
- $nilai = abs($nilai);
- $huruf = array("", "Satu", "Dua", "Tiga", "Empat", "Lima", "Enam", "Tujuh", "Delapan", "Sembilan", "Sepuluh", "Sebelas");
- $temp = "";
- if ($nilai < 12) {
- $temp = " " . $huruf[$nilai];
- } else if ($nilai < 20) {
- $temp = penyebut($nilai - 10) . " Belas";
- } else if ($nilai < 100) {
- $temp = penyebut($nilai / 10) . " Puluh" . penyebut($nilai % 10);
- } else if ($nilai < 200) {
- $temp = " Seratus" . penyebut($nilai - 100);
- } else if ($nilai < 1000) {
- $temp = penyebut($nilai / 100) . " Ratus" . penyebut($nilai % 100);
- } else if ($nilai < 2000) {
- $temp = " Seribu" . penyebut($nilai - 1000);
- } else if ($nilai < 1000000) {
- $temp = penyebut($nilai / 1000) . " Ribu" . penyebut($nilai % 1000);
- } else if ($nilai < 1000000000) {
- $temp = penyebut($nilai / 1000000) . " Juta" . penyebut($nilai % 1000000);
- } else if ($nilai < 1000000000000) {
- $temp = penyebut($nilai / 1000000000) . " Milyar" . penyebut(fmod($nilai, 1000000000));
- } else if ($nilai < 1000000000000000) {
- $temp = penyebut($nilai / 1000000000000) . " Trilyun" . penyebut(fmod($nilai, 1000000000000));
- }
- return $temp;
- }
- function terbilang($nilai)
- {
- if ($nilai < 0) {
- $hasil = "minus " . trim(penyebut($nilai));
- } else {
- $hasil = trim(penyebut($nilai));
- }
- return $hasil;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement