Example #1
0
 public function terbilang()
 {
     $this->load->helper("terbilang");
     $angka = "87,5";
     echo $angka;
     echo "<p>Terbilang : </p>";
     echo ucwords(number_to_words($angka));
     echo ucwords(number_to_words("1,000"));
 }
Example #2
0
/**
 * Number to words.
 *
 * @param int $number
 *
 * @return string
 */
function number_to_words($number)
{
    $words = array('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 30 => 'thirty', 40 => 'fourty', 50 => 'fifty', 60 => 'sixty', 70 => 'seventy', 80 => 'eighty', 90 => 'ninety', 100 => 'hundred', 1000 => 'thousand');
    $number_in_words = '';
    if (is_numeric($number)) {
        $number = (int) round($number);
        if ($number < 0) {
            $number = -$number;
            $number_in_words = 'minus ';
        }
        if ($number > 1000) {
            $number_in_words = $number_in_words . number_to_words(floor($number / 1000)) . " " . $words[1000];
            $hundreds = $number % 1000;
            $tens = $hundreds % 100;
            if ($hundreds > 100) {
                $number_in_words = $number_in_words . ", " . number_to_words($hundreds);
            } elseif ($tens) {
                $number_in_words = $number_in_words . " and " . number_to_words($tens);
            }
        } elseif ($number > 100) {
            $number_in_words = $number_in_words . number_to_words(floor($number / 100)) . " " . $words[100];
            $tens = $number % 100;
            if ($tens) {
                $number_in_words = $number_in_words . " and " . number_to_words($tens);
            }
        } elseif ($number > 20) {
            $number_in_words = $number_in_words . " " . $words[10 * floor($number / 10)];
            $units = $number % 10;
            if ($units) {
                $number_in_words = $number_in_words . number_to_words($units);
            }
        } else {
            $number_in_words = $number_in_words . " " . $words[$number];
        }
        return trim($number_in_words);
    }
    return 'unknown';
}
Example #3
0
 function number_to_words($number)
 {
     $number = str_replace(",", "", $number);
     // to remove commas
     $Cr = floor($number / 10000000);
     /* Crore  */
     $number -= $Cr * 10000000;
     $Gn = floor($number / 100000);
     /* Lacs  */
     $number -= $Gn * 100000;
     $kn = floor($number / 1000);
     /* Thousands */
     $number -= $kn * 1000;
     $Hn = floor($number / 100);
     /* Hundreds */
     $number -= $Hn * 100;
     $Dn = floor($number / 10);
     /* Tens  */
     $n = $number % 10;
     /* Ones */
     $cn = round(($number - floor($number)) * 100);
     /* Cents */
     $result = "";
     if ($Cr) {
         $result .= number_to_words($Cr) . " Crore ";
     }
     if ($Gn) {
         $result .= number_to_words($Gn) . " Lac";
     }
     if ($kn) {
         $result .= (empty($result) ? "" : " ") . number_to_words($kn) . " Thousand";
     }
     if ($Hn) {
         $result .= (empty($result) ? "" : " ") . number_to_words($Hn) . " Hundred";
     }
     $ones = array("", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eightteen", "Nineteen");
     $tens = array("", "", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty", "Seventy", "Eigthy", "Ninety");
     if ($Dn || $n) {
         if (!empty($result)) {
             $result .= " and ";
         }
         if ($Dn < 2) {
             $result .= $ones[$Dn * 10 + $n];
         } else {
             $result .= $tens[$Dn];
             if ($n) {
                 $result .= "-" . $ones[$n];
             }
         }
     }
     if ($cn) {
         if (!empty($result)) {
             $result .= ' and ';
         }
         $title = $cn == 1 ? 'paisa ' : 'paisa';
         $result .= strtolower(number_to_words($cn)) . ' ' . $title;
     }
     if (empty($result)) {
         $result = "zero";
     }
     return $result;
 }
Example #4
0
        <tr height=19 style='height:14.25pt'>
            <!--  <td height=19 class=xl663737 style='height:14.25pt'></td>-->
            <td colspan=2 class=xl693737>Total Amount</td>
            <td class=xl673737 align=right></td>
            <td class=xl663737><?php 
echo $total;
?>
</td>
            <td class=xl663737></td>
            <td colspan=1 class=xl683737><b>Admin Accounts:</b></td>
            <td class=xl663737>___________________________</td>
        </tr>
        <tr height=19 style='height:14.25pt'>
            <!--  <td height=19 class=xl663737 style='height:14.25pt'></td>-->
            <td colspan=3 class=xl703737><?php 
echo strtoupper(number_to_words($total));
?>
 ONLY</td>
            <td class=xl663737></td>
            <td class=xl663737></td>
            <td class=xl663737></td>
            <td class=xl663737></td>
            <td class=xl663737></td>
        </tr>
        <tr height=19 style='height:14.25pt'>
            <td colspan=8 height=19 class=xl753737 style='height:14.25pt'><?php 
echo $vOptions->note;
echo $vchComments;
?>
</td>
            <td class=xl663737></td>
function number_to_words($number)
{
    $hyphen = '-';
    $conjunction = ' and ';
    $separator = ', ';
    $negative = 'negative ';
    $decimal = ' point ';
    $dictionary = array(0 => 'zero', 1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five', 6 => 'six', 7 => 'seven', 8 => 'eight', 9 => 'nine', 10 => 'ten', 11 => 'eleven', 12 => 'twelve', 13 => 'thirteen', 14 => 'fourteen', 15 => 'fifteen', 16 => 'sixteen', 17 => 'seventeen', 18 => 'eighteen', 19 => 'nineteen', 20 => 'twenty', 30 => 'thirty', 40 => 'fourty', 50 => 'fifty', 60 => 'sixty', 70 => 'seventy', 80 => 'eighty', 90 => 'ninety', 100 => 'hundred', 1000 => 'thousand', 1000000 => 'million', 1000000000 => 'billion', 1000000000000 => 'trillion', 1000000000000000 => 'quadrillion', 1000000000000000000 => 'quintillion');
    if (!is_numeric($number)) {
        return false;
    }
    if ($number >= 0 && (int) $number < 0 || (int) $number < 0 - PHP_INT_MAX) {
        // overflow
        trigger_error('number_to_words only accepts numbers between -' . PHP_INT_MAX . ' and ' . PHP_INT_MAX, E_USER_WARNING);
        return false;
    }
    if ($number < 0) {
        return $negative . number_to_words(abs($number));
    }
    $string = $fraction = null;
    if (strpos($number, '.') !== false) {
        list($number, $fraction) = explode('.', $number);
    }
    switch (true) {
        case $number < 21:
            $string = $dictionary[$number];
            break;
        case $number < 100:
            $tens = (int) ($number / 10) * 10;
            $units = $number % 10;
            $string = $dictionary[$tens];
            if ($units) {
                $string .= $hyphen . $dictionary[$units];
            }
            break;
        case $number < 1000:
            $hundreds = $number / 100;
            $remainder = $number % 100;
            $string = $dictionary[$hundreds] . ' ' . $dictionary[100];
            if ($remainder) {
                $string .= $conjunction . number_to_words($remainder);
            }
            break;
        default:
            $baseUnit = pow(1000, floor(log($number, 1000)));
            $numBaseUnits = (int) ($number / $baseUnit);
            $remainder = $number % $baseUnit;
            $string = number_to_words($numBaseUnits) . ' ' . $dictionary[$baseUnit];
            if ($remainder) {
                $string .= $remainder < 100 ? $conjunction : $separator;
                $string .= number_to_words($remainder);
            }
            break;
    }
    if (null !== $fraction && is_numeric($fraction)) {
        $string .= $decimal;
        $words = array();
        foreach (str_split((string) $fraction) as $number) {
            $words[] = $dictionary[$number];
        }
        $string .= implode(' ', $words);
    }
    return strtoupper($string);
}
Example #6
0
function number_to_words($Number)
{
    if ($Number < 0 or $Number > 999999999) {
        prnMsg(_('Number is out of the range of numbers that can be expressed in words'), 'error');
        return _('error');
    }
    $Millions = floor($Number / 1000000);
    $Number -= $Millions * 1000000;
    $Thousands = floor($Number / 1000);
    $Number -= $Thousands * 1000;
    $Hundreds = floor($Number / 100);
    $Number -= $Hundreds * 100;
    $NoOfTens = floor($Number / 10);
    $NoOfOnes = $Number % 10;
    $NumberInWords = '';
    if ($Millions) {
        $NumberInWords .= number_to_words($Millions) . ' ' . _('million');
    }
    if ($Thousands) {
        $NumberInWords .= (empty($NumberInWords) ? '' : ' ') . number_to_words($Thousands) . ' ' . _('thousand');
    }
    if ($Hundreds) {
        $NumberInWords .= (empty($NumberInWords) ? '' : ' ') . number_to_words($Hundreds) . ' ' . _('hundred');
    }
    $Ones = array(0 => '', 1 => _('one'), 2 => _('two'), 3 => _('three'), 4 => _('four'), 5 => _('five'), 6 => _('six'), 7 => _('seven'), 8 => _('eight'), 9 => _('nine'), 10 => _('ten'), 11 => _('eleven'), 12 => _('twelve'), 13 => _('thirteen'), 14 => _('fourteen'), 15 => _('fifteen'), 16 => _('sixteen'), 17 => _('seventeen'), 18 => _('eighteen'), 19 => _('nineteen'));
    $Tens = array(0 => '', 1 => '', 2 => _('twenty'), 3 => _('thirty'), 4 => _('forty'), 5 => _('fifty'), 6 => _('sixty'), 7 => _('seventy'), 8 => _('eighty'), 9 => _('ninety'));
    if ($NoOfTens or $NoOfOnes) {
        if (!empty($NumberInWords)) {
            $NumberInWords .= ' ' . _('and') . ' ';
        }
        if ($NoOfTens < 2) {
            $NumberInWords .= $Ones[$NoOfTens * 10 + $NoOfOnes];
        } else {
            $NumberInWords .= $Tens[$NoOfTens];
            if ($NoOfOnes) {
                $NumberInWords .= '-' . $Ones[$NoOfOnes];
            }
        }
    }
    if (empty($NumberInWords)) {
        $NumberInWords = _('zero');
    }
    return $NumberInWords;
}
Example #7
0
" class="anchor button white medium wow fadeInUp"><?php 
uf('ban_button_text');
?>
</a>
        </article>
    </div>
    <!-- //Hero -->

    <!-- Tab navigation -->
    <?php 
$ctas = get_uf_repeater('cta_repeater');
if (!empty($ctas)) {
    if (count($ctas) > 4) {
        $class = 'four';
    } else {
        $class = number_to_words(count($ctas));
    }
    echo '<nav class="tabs ' . $class . '" role="navigation">
            <ul class="wrap">';
    for ($i = 0; $i < (count($ctas) > 4 ? 4 : count($ctas)); $i++) {
        echo '<li><a href="' . $ctas[$i]['cta_link'] . '" title="' . strip_tags($ctas[$i]['cta_text']) . '">
                    <img src="' . $ctas[$i]['cta_image'] . '" alt="" /> ' . $ctas[$i]['cta_text'] . '
                </a></li>';
    }
    echo '</ul>
            </nav>';
}
?>
    <!-- //Tab navigation -->

    <!-- Call to action -->
                    </figure>
                    <!-- //Item -->
                <?php 
            }
            ?>
            </div>
            <!-- //Gallery -->
            <?php 
        }
        ?>

            <!-- Content -->
            <div class="content">
                <!-- Tab navigation -->
                <nav class="tabs <?php 
        echo number_to_words($number_of_tabs);
        ?>
" role="navigation" id="tab-navigation">
                    <ul class="wrap">
                        <li><a href="#tab1" title="Description">
                                <span class="icojam_info_3"></span> Description
                            </a></li>
                        <?php 
        if (!empty($full_specs)) {
            ?>
                        <li><a href="#tab2" title="Specifications">
                                <span class="icojam_document"></span> Specifications
                            </a></li>
                        <?php 
        }
        ?>
Example #9
0
function number_to_words($number)
{
    if ($number > 999999999) {
        //        throw new Exception("Number is out of range");
        $result = "Number is out of range";
    }
    $Gn = floor($number / 1000000);
    /* Millions (giga) */
    $number -= $Gn * 1000000;
    $kn = floor($number / 1000);
    /* Thousands (kilo) */
    $number -= $kn * 1000;
    $Hn = floor($number / 100);
    /* Hundreds (hecto) */
    $number -= $Hn * 100;
    $Dn = floor($number / 10);
    /* Tens (deca) */
    $n = $number % 10;
    /* Ones */
    $cn = round(($number - floor($number)) * 100);
    /* Cents */
    $result = "";
    if ($Gn) {
        $result .= number_to_words($Gn) . " Million";
    }
    if ($kn) {
        $result .= (empty($result) ? "" : " ") . number_to_words($kn) . " Thousand";
    }
    if ($Hn) {
        $result .= (empty($result) ? "" : " ") . number_to_words($Hn) . " Hundred";
    }
    $ones = array("", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eightteen", "Nineteen");
    $tens = array("", "", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty", "Seventy", "Eigthy", "Ninety");
    if ($Dn || $n) {
        if (!empty($result)) {
            $result .= " and ";
        }
        if ($Dn < 2) {
            $result .= $ones[$Dn * 10 + $n];
        } else {
            $result .= $tens[$Dn];
            if ($n) {
                $result .= "-" . $ones[$n];
            }
        }
    }
    if ($cn) {
        if (!empty($result)) {
            $result .= ' and ';
        }
        $title = $cn == 1 ? 'cent ' : 'cents';
        $result .= strtolower(number_to_words($cn)) . ' ' . $title;
    }
    if (empty($result)) {
        $result = "zero";
    }
    return $result;
}