Make a function calculate rate to Indonesian words in PHP


= 0 && $n <= 11) {
        $result .= " " . $units[$n];
    } elseif ($n >= 12 && $n <= 19) {
        $result .= in_words($n % 10) . " Belas";
    } elseif ($n >= 20 && $n <= 99) {
        $result .= in_words(floor($n / 10)) . " Puluh" . in_words($n % 10);
    } elseif ($n >= 100 && $n <= 199) {
        $result .= " Seratus" . in_words($n - 100);
    } elseif ($n >= 200 && $n <= 999) {
        $result .= in_words(floor($n / 100)) . " Ratus" . in_words($n % 100);
    } elseif ($n > 1000 && $n <= 1999) {
        $result .= " Seribu" . in_words($n - 1000);
    } elseif ($n >= 2000 && $n <= 999999) {
        $result .= in_words(floor($n / 1000)) . " Ribu" . in_words($n % 1000);
    } elseif ($n >= 1000000 && $n <= 999999999) {
        $result .= in_words(floor($n / 1000000)) . " Juta" . in_words($n % 1000000);
    } else {
        $result .= in_words(floor($n / 1000000000)) . " Milyar" . in_words($n %
            1000000000);
    }
    return $result;
}
?>

Leave a Reply

Your email address will not be published.