P. Donny,
Thx untuk URL yang diberikan.
mengenai terbilang, kemarin saya sudah buat tapi terkendala dengan kata
"seribu" dan "satu ribu"
Mungkin ada clue cara merubah kata satu ribu jadi seribu ?
Code yg saya buat adalah sbb :
function Terbilang($codeval) {
if(strlen($codeval)<9) { $codeval =
str_repeat("0",9-strlen($codeval)).$codeval; }
//if(strlen($codeval)==3) { $result = TigaDigit($codeval); }
//if(strlen($codeval)==6) { $result =
TigaDigit(substr($codeval,0,3)).'Ribu
'.TigaDigit(substr($codeval,3,3)); }
//if(strlen($codeval)==9) { $result =
TigaDigit(substr($codeval,0,3)).'Juta
'.TigaDigit(substr($codeval,3,3)).'Ribu '.TigaD
igit(substr($codeval,6,3)); }
for($i=0;$i<9;$i=$i+3) {
$nilai=substr($codeval,$i,3);
$result .= TigaDigit($nilai);
if($i==0) { $result .= 'Juta '; }
if($i==3) { $result .= 'Ribu '; }
if($i==6) { $result .= 'Rupiah.'; }
}
return $result;
}
function TigaDigit($codeval) {
if(strlen($codeval)<3) { $codeval =
str_repeat("0",3-strlen($codeval)).$codeval; }
$Angka = array('','Satu ','Dua ','Tiga ','Empat ','Lima
','Enam ','Tujuh ','Delapan ','Sembilan ','Sepuluh
','Sebelas ','Du
a Belas ','Tiga Belas ','Empat Belas ','Lima Belas ','Enam Belas
','Tujuh Belas ','Sembilan Belas ');
if($codeval>0) {
$LastTwo = substr($codeval,1,2);
if($LastTwo<20) {
if($LastTwo<10) {
$LastTwo = substr($LastTwo,1,1);
$tLastTwo = $Angka[$LastTwo];
} else {
$tLastTwo = $Angka[$LastTwo];
}
} else {
$DigitOne = substr($LastTwo,0,1);
$DigitTwo = substr($LastTwo,1,1);
$tLastTwo = $Angka[$DigitOne].'Puluh '.$Angka[$DigitTwo];
}
$DigitThree = substr($codeval,0,1);
if($DigitThree==1) { $tDigitThree = 'Seratus '; }
elseif($DigitThree>1) { $tDigitThree = $Angka[$DigitThree].'Ratus '; }
el
se { $tDigitThree=''; }
$Result = $tDigitThree.$tLastTwo;
} else { $Result=''; }
return $Result;
}
PD
On 1/3/2009, "Donny Kurnia" <[email protected]> wrote:
>Fungsi terbilang buatan saya ada di:
>http://pastie.org/351579
>
>--
>Donny Kurnia
>http://hantulab.blogspot.com
>http://www.plurk.com/user/donnykurnia
>
>
>--
>Berhenti langganan: [email protected]
>Arsip dan info: http://linux.or.id/milis
>
>
>
--
Berhenti langganan: [email protected]
Arsip dan info: http://linux.or.id/milis