note 66645 added to language.types.array
| From: | dot) | Date: | Thu, 25 May 2006 13:52:39 +0000 |
| Subject: | note 66645 added to language.types.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-112207@lists.php.net to get a copy of this message | ||
this is simpler tha function display_angka_bilangan by ktaufik(at)gmail(dot)com (16-Feb-2005 12:40)
<?
/*
*
* Class : Terbilang
* Spell quantity numbers in Indonesian or Malay Language
*
*
* author: huda m elmatsani
* 21 September 2004
* freeware
*
* example:
* $bilangan = new Terbilang;
* echo $bilangan -> eja(137);
* result: seratus tiga puluh tujuh
*
*
*/
Class Terbilang {
function terbilang() {
$this->dasar =
array(1=>'satu','dua','tiga','empat','lima','enam',
'tujuh','delapan','sembilan');
$this->angka = array(1000000000,1000000,1000,100,10,1);
$this->satuan =
array('milyar','juta','ribu','ratus','puluh','');
}
function eja($n) {
$i=0;
while($n!=0){
$count = (int)($n/$this->angka[$i]);
if($count>=10) $str .= $this->eja($count). " ".$this->satuan[$i]."
";
else if($count > 0 && $count < 10)
$str .= $this->dasar[$count] . " ".$this->satuan[$i]." ";
$n -= $this->angka[$i] * $count;
$i++;
}
$str = preg_replace("/satu puluh (\w+)/i","\\1 belas",$str);
$str = preg_replace("/satu (ribu|ratus|puluh|belas)/i","se\\1",$str);
return $str;
}
}
?>
----
Server IP: 66.163.161.117
Probable Submitter: 61.5.17.23
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/language.types.array.php
Edit -- http://master.php.net/note/edit/66645
Del: integrated -- http://master.php.net/note/delete/66645/integrated
Del: useless -- http://master.php.net/note/delete/66645/useless
Del: bad code -- http://master.php.net/note/delete/66645/bad+code
Del: spam -- http://master.php.net/note/delete/66645/spam
Del: non-english -- http://master.php.net/note/delete/66645/non-english
Del: in docs -- http://master.php.net/note/delete/66645/in+docs
Del: other reasons-- http://master.php.net/note/delete/66645
Reject -- http://master.php.net/note/reject/66645
Search -- http://master.php.net/manage/user-notes.php