function convert_number_to_words($number) { $hyphen = '-'; $conjunction = ' and '; $separator = ', '; $negative = 'negative '; $decimal = ' point '; $dictionary = array(0 => 'zero', 1 => 'satu', 2 => 'dua', 3 => 'tiga', 4 => 'empat', 5 => 'lima', 6 => 'enam', 7 => 'tujuh', 8 => 'delapan', 9 => 'sembilan', 10 => 'sepuluh', 11 => 'sebelas', 12 => 'dua belas', 13 => 'tiga belas', 14 => 'empat belas', 15 => 'lima belas', 16 => 'enam belas', 17 => 'tujuh belas', 18 => 'delapan belas', 19 => 'sembilan belas', 20 => 'dua puluh', 30 => 'tiga puluh', 40 => 'empat puluh', 50 => 'lima puluh', 60 => 'enam puluh', 70 => 'tujuh puluh', 80 => 'delapan puluh', 90 => 'sembilan puluh', 100 => 'seratus', 1000 => 'seribu', 1000000 => 'satu juta', 1000000000 => 'milyar', 1000000000000 => 'trilyun', 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('convert_number_to_words only accepts numbers between -' . PHP_INT_MAX . ' and ' . PHP_INT_MAX, E_USER_WARNING); return false; } if ($number < 0) { return $negative . convert_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 . convert_number_to_words($remainder); } break; default: $baseUnit = pow(1000, floor(log($number, 1000))); $numBaseUnits = (int) ($number / $baseUnit); $remainder = $number % $baseUnit; $string = convert_number_to_words($numBaseUnits) . ' ' . $dictionary[$baseUnit]; if ($remainder) { $string .= $remainder < 100 ? $conjunction : $separator; $string .= convert_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 $string; }
<td><label>Order Total:</label></td> <td colspan="3"><b> <span> <?php $total = $row->order_total; echo country_currency($total); ?> </span> </b> </td> </tr> <tr> <td><label>Order Total In Word:</label></td> <td colspan="3"> <?php echo '<b>' . convert_number_to_words($total) . ' Tk. Only.</b>'; ?> </td> </tr> <tr> <td><label>Email Id:</label></td> <td width="31%"><p><?php echo $row->email; ?> </p></td> <td width="12%"> </td> <td width="37%"> </td> </tr> <tr> <td><label>Contact No:</label></td> <td><p><?php
function convert_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'); if (!is_numeric($number)) { return FALSE; } if ($number >= 0 && (int) $number < 0 || (int) $number < 0 - PHP_INT_MAX) { // overflow trigger_error('convert_number_to_words only accepts numbers between -' . PHP_INT_MAX . ' and ' . PHP_INT_MAX, E_USER_WARNING); return FALSE; } if ($number < 0) { return $negative . convert_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 . convert_number_to_words($remainder); } break; default: $baseUnit = pow(1000, floor(log($number, 1000))); $numBaseUnits = (int) ($number / $baseUnit); $remainder = $number % $baseUnit; $string = convert_number_to_words($numBaseUnits) . ' ' . $dictionary[$baseUnit]; if ($remainder) { $string .= $remainder < 100 ? $conjunction : $separator; $string .= convert_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 $string; }
/** * @author: lmkhang - skype * @date: 2016-02-03 * Formula for Payment Amount */ public function payment_amount($original_amount, $payment_method) { //get Setting value $currency = \App\Config::where(['prefix' => 'payment', 'name' => 'currency', 'del_flg' => 1])->get()[0]['value']; $tax_pay_bank = \App\Config::where(['prefix' => 'payment', 'name' => 'tax_pay_bank', 'del_flg' => 1])->get()[0]['value']; $amount = $payment_method == 1 ? $original_amount * $currency - $tax_pay_bank : $original_amount; return ['currency' => $payment_method == 1 ? $currency : '', 'tax_pay_bank' => $payment_method == 1 ? $tax_pay_bank : '', 'original_amount' => $original_amount, 'amount' => $amount, 'currency_string' => '$', 'payment_method' => $payment_method, 'string_original_amount' => $original_amount . '$', 'string_amount' => $payment_method == 1 ? number_format($amount, 0, ',', '.') . ' VND' : number_format($amount, 2, ',', '.') . ' $', 'net_amount_word_info' => $payment_method == 1 ? convert_number_to_words(str_replace(array(','), array(''), number_format($amount, 0)), 'vn') . ' Việt Nam Đồng' : convert_number_to_words(str_replace(array(','), array(''), number_format($amount, 2)), 'en') . ' PAYPAL dollars']; }
</tr> <tr> <td height="50" colspan="2" class="chang" valign="top" align="left">Customer Bank Details:- </td> <td colspan="10" align="left"><?php echo nl2br($row['c_bnk_d']); ?> </td> </td> </tr> <tr> <td colspan="10" align="left"> US DOLLARS:- <h4> <?php echo strtoupper(convert_number_to_words($row['grand_total'])) . ' ONLY'; ?> </h4> </td> <td style="text-align:right; font-weight:800; ">TOTAL:-</td> <td>USD <?php echo $row['grand_total']; ?> </td> </tr> </table> <br> <p style="text-align: left; width:49%; display: inline-block;"><font size="2">Verified By<br> DT001</font> </p> <p style="text-align: right; width:40%; display: inline-block;"><font size="2">Approved By<br><font style="margin-right:20px;"> NC007</font> </font></p>
</td> <td > <?php if ($hostel_required == 1) { echo sprintf('%0.2f', $total_fee = $total_fee); } else { echo sprintf('%0.2f', $total_fee = $total_fee - $hostel_fee); } ?> </td> </tr> <tr> <td colspan="2"> Amount: <?php echo $wrd = convert_number_to_words($total_fee) . " Only"; ?> </td> </tr> <tr> <td colspan="2"><input type="hidden" name="amount" value="<?php echo $total_fee = number_format($total_fee, 2, '.', ''); ?> "></td> </tr> <tr> <td colspan="2"> <center> <button class="btn btn-primary" type="submit"> Make payment</button> </center>
/** * wcj_order_total_in_words. * * @version 2.4.0 */ function wcj_order_total_in_words($atts) { $order_total = true === $atts['excl_tax'] ? $this->the_order->get_total() - $this->the_order->get_total_tax() : $this->the_order->get_total(); $order_total_whole = intval($order_total); $order_total_decimal = round(($order_total - $order_total_whole) * 100); $the_number_in_words = '%s %s'; $the_number_in_words .= 0 != $order_total_decimal ? ', %s %s.' : '.'; $dollars = $atts['whole']; $cents = $atts['decimal']; return sprintf($the_number_in_words, ucfirst(convert_number_to_words($order_total_whole)), $dollars, ucfirst(convert_number_to_words($order_total_decimal)), $cents); }
<th colspan=8>PLEASE DO NOT FILL UP ACCOUNTING USE ONLY</th> </tr> <?php $AMOUNT = '11600.25'; $amount = explode('.', $AMOUNT); $num_arr = count($amount); if ($num_arr == 2) { $AMOUNT = number_format($AMOUNT, 2, '.', ''); $amount = explode('.', $AMOUNT); $whole = $amount[0]; $dec = $amount[1]; $cents = $dec . '/100'; $words = convert_number_to_words($whole); $amountinwords = "***" . $words . " & " . $cents . "***"; } else { $words = convert_number_to_words($AMOUNT); $amountinwords = "***" . $words . " PESOS ONLY***"; } ?> <tr> <td colspan=8><?php echo $amountinwords; ?> </td> </tr> <tr class="status-label"> <td colspan=8>AMOUNT IN WORDS</td> </tr>
</font></td> </tr> <tr> <td></td> <td><font size="2">Payment</font></td> <td><font size="2"><?php echo $current_pay['paid_amount']; ?> </font></td> </tr> <tr> <td></td> <td><font size="2">Total Due</font></td> <td><font size="2"><?php echo $total - $total_paid_sum; ?> </font></td> </tr> </table> </div> <span><font size="2">In Words: <?php echo convert_number_to_words($current_pay['paid_amount']) . " Rupees Only"; ?> </font></span></br> <span><b><font size="2">Received By: <?php echo $username; ?> </font></b></span></br> <span><font size="2">Thank You !</font></span> </div>
<td class="t_a_right"><b> <?php if ($invoice[0]['total_amount'] < $invoice[0]['advance']) { echo "0"; } else { echo $invoice[0]['total_amount'] - $invoice[0]['advance']; } ?> </b></td> </tr> </tfoot> </table> </div> <div class="CB"></div> <div class="rupee_word">Fig in words <?php echo convert_number_to_words($invoice[0]['total_amount']); ?> ONLY</div> <div class="CB"></div> <div class="paninfo">PAN:<?php echo $invoice[0]['pan']; ?> <br> SERVICE TAX REGN NO:- <?php echo $invoice[0]['sertexno']; ?> </div> <div class="Stamp"> For <?php echo $invoice[0]['companyname']; ?>
public function convert_number_to_words($number) { // $hyphen = '-'; $hyphen = " "; // $conjunction = ' and '; $conjunction = ''; $separator = ''; $negative = 'negative '; $decimal = ' point '; $dictionary = array(0 => 'nol', 1 => 'Satu', 2 => 'Dua', 3 => 'tiga', 4 => 'Empat', 5 => 'Lima', 6 => 'Enam', 7 => 'Tujuh', 8 => 'Delapan', 9 => 'Sembilan', 10 => 'Sepuluh', 11 => 'Sebelas', 12 => 'Dua Belas', 13 => 'Tiga Belas', 14 => 'Tmpat Belas', 15 => 'Lima Belas', 16 => 'Enam Belas', 17 => 'Tujuh Belas', 18 => 'Delapan Belas', 19 => 'Sembilan Belas', 20 => 'Dua Puluh', 30 => 'Tiga Puluh', 40 => 'Empat Puluh', 50 => 'Lima Puluh', 60 => 'Enam Puluh', 70 => 'Tujuh Puluh', 80 => 'Delapan Puluh', 90 => 'Sembilan Puluh', 100 => 'Ratus ', 1000 => 'Ribu ', 1000000 => 'Juta ', 1000000000 => 'Miliar ', 1000000000000 => 'Triliun ', 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('convert_number_to_words only accepts numbers between -' . PHP_INT_MAX . ' and ' . PHP_INT_MAX, E_USER_WARNING); return false; } if ($number < 0) { return $negative . convert_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; if ($hundreds < 2) { $string = 'se' . $dictionary[100] . " "; } else { $string = $dictionary[$hundreds] . ' ' . $dictionary[100] . ' '; } if ($remainder) { $string .= $conjunction . $this->convert_number_to_words($remainder); } break; default: $baseUnit = pow(1000, floor(log($number, 1000))); $numBaseUnits = (int) ($number / $baseUnit); $remainder = $number % $baseUnit; $string = $this->convert_number_to_words($numBaseUnits) . ' ' . $dictionary[$baseUnit]; if ($remainder) { $string .= $remainder < 100 ? $conjunction : $separator; $string .= $this->convert_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 $string; }
public function convert_number_to_word_month($number) { $hyphen = ' '; $conjunction = ' '; $separator = ' '; $negative = 'âm '; $decimal = ' phẩy '; $dictionary = array(1 => 'January', 2 => 'February', 3 => 'March', 4 => 'April', 5 => 'May', 6 => 'June', 7 => 'July', 8 => 'August', 9 => 'September', 10 => 'October', 11 => 'November', 12 => 'December'); if (!is_numeric($number)) { return false; } if ($number >= 0 && (int) $number < 0 || (int) $number < 0 - PHP_INT_MAX) { // overflow trigger_error('convert_number_to_words only accepts numbers between -' . PHP_INT_MAX . ' and ' . PHP_INT_MAX, E_USER_WARNING); return false; } if ($number < 0) { return $negative . convert_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 . convert_number_to_words($remainder); } break; default: $baseUnit = pow(1000, floor(log($number, 1000))); $numBaseUnits = (int) ($number / $baseUnit); $remainder = $number % $baseUnit; $string = convert_number_to_words($numBaseUnits) . ' ' . $dictionary[$baseUnit]; if ($remainder) { $string .= $remainder < 100 ? $conjunction : $separator; $string .= convert_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 $string; }
function convert_number_to_words($number, $lang = 'vn') { if ($lang === 'en') { $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'); } else { if ($lang === 'vn') { $hyphen = ' '; $conjunction = ' lẻ '; $separator = ' - '; $negative = 'âm '; $decimal = ''; $dictionary = array(0 => 'không', 1 => 'một', 2 => 'hai', 3 => 'ba', 4 => 'bốn', 5 => 'năm', 6 => 'sáu', 7 => 'bảy', 8 => 'tám', 9 => 'chín', 10 => 'mười', 11 => 'mười một', 12 => 'mười hai', 13 => 'mười ba', 14 => 'mười bốn', 15 => 'mười năm', 16 => 'mười sáu', 17 => 'mười bảy', 18 => 'mười tám', 19 => 'mười chín', 20 => 'hai mươi', 30 => 'ba mươi', 40 => 'bốn mươi', 50 => 'năm mươi', 60 => 'sáu mươi', 70 => 'bảy mươi', 80 => 'tám mươi', 90 => 'chín mươi', 100 => 'trăm', 1000 => 'ngàn', 1000000 => 'triệu', 1000000000 => 'tỉ', 1000000000000 => 'ngàn tỉ', 1000000000000000 => 'triệu tỉ', 1000000000000000000 => 'tỉ tỉ'); } } if (!is_numeric($number)) { return false; } if ($number >= 0 && (int) $number < 0 || (int) $number < 0 - PHP_INT_MAX) { // overflow trigger_error('convert_number_to_words only accepts numbers between -' . PHP_INT_MAX . ' and ' . PHP_INT_MAX, E_USER_WARNING); return false; } if ($number < 0) { return $negative . convert_number_to_words(abs($number), $lang); } $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 . convert_number_to_words($remainder, $lang); } break; default: $baseUnit = pow(1000, floor(log($number, 1000))); $numBaseUnits = (int) ($number / $baseUnit); $remainder = $number % $baseUnit; $string = convert_number_to_words($numBaseUnits, $lang) . ' ' . $dictionary[$baseUnit]; if ($remainder) { $string .= $remainder < 100 ? $conjunction : $separator; $string .= convert_number_to_words($remainder, $lang); } 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 ucwords($string); }
function convert_number_to_words($number) { $hyphen = ' '; $conjunction = ' '; $separator = ' '; $negative = 'âm '; $decimal = ' phẩy '; $dictionary = array(0 => 'Không', 1 => 'Một', 2 => 'Hai', 3 => 'Ba', 4 => 'Bốn', 5 => 'Năm', 6 => 'Sáu', 7 => 'Bảy', 8 => 'Tám', 9 => 'Chín', 10 => 'Mười', 11 => 'Mười một', 12 => 'Mười hai', 13 => 'Mười ba', 14 => 'Mười bốn', 15 => 'Mười năm', 16 => 'Mười sáu', 17 => 'Mười bảy', 18 => 'Mười tám', 19 => 'Mười chín', 20 => 'Hai mươi', 30 => 'Ba mươi', 40 => 'Bốn mươi', 50 => 'Năm mươi', 60 => 'Sáu mươi', 70 => 'Bảy mươi', 80 => 'Tám mươi', 90 => 'Chín mươi', 100 => 'trăm', 1000 => 'ngàn', 1000000 => 'triệu', 1000000000 => 'tỷ', 1000000000000 => 'nghìn tỷ', 1000000000000000 => 'ngàn triệu triệu', 1000000000000000000 => 'tỷ tỷ'); if (!is_numeric($number)) { return false; } if ($number >= 0 && (int) $number < 0 || (int) $number < 0 - PHP_INT_MAX) { // overflow trigger_error('convert_number_to_words only accepts numbers between -' . PHP_INT_MAX . ' and ' . PHP_INT_MAX, E_USER_WARNING); return false; } if ($number < 0) { return $negative . convert_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 . convert_number_to_words($remainder); } break; default: $baseUnit = pow(1000, floor(log($number, 1000))); $numBaseUnits = (int) ($number / $baseUnit); $remainder = $number % $baseUnit; $string = convert_number_to_words($numBaseUnits) . ' ' . $dictionary[$baseUnit]; if ($remainder) { $string .= $remainder < 100 ? $conjunction : $separator; $string .= convert_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 $string; }
/** * wcj_order_total_in_words. * * @version 2.5.9 */ function wcj_order_total_in_words($atts) { $order_total = true === $atts['excl_tax'] ? $this->the_order->get_total() - $this->the_order->get_total_tax() : $this->the_order->get_total(); $order_total_whole = intval($order_total); $order_total_decimal = round(($order_total - $order_total_whole) * 100); $the_number_in_words = '%s %s'; $the_number_in_words .= 0 != $order_total_decimal ? ', %s %s.' : '.'; $dollars = $atts['whole']; $cents = $atts['decimal']; switch ($atts['lang']) { case 'LT': return sprintf($the_number_in_words, $this->mb_ucfirst(convert_number_to_words_lt($order_total_whole)), $dollars, $this->mb_ucfirst(convert_number_to_words_lt($order_total_decimal)), $cents); case 'BG': return sprintf($the_number_in_words, $this->mb_ucfirst(trim(convert_number_to_words_bg($order_total_whole))), $dollars, $this->mb_ucfirst(trim(convert_number_to_words_bg($order_total_decimal))), $cents); default: // 'EN' return sprintf($the_number_in_words, ucfirst(convert_number_to_words($order_total_whole)), $dollars, ucfirst(convert_number_to_words($order_total_decimal)), $cents); } }
public function convert_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 => 'Qintillion'); if (!is_numeric($number)) { return false; } if ($number >= 0 && (int) $number < 0 || (int) $number < 0 - PHP_INT_MAX) { // overflow trigger_error('convert_number_to_words only accepts numbers between -' . PHP_INT_MAX . ' and ' . PHP_INT_MAX, E_USER_WARNING); return false; } if ($number < 0) { return $negative . convert_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 . $this->convert_number_to_words($remainder); } break; default: $baseUnit = pow(1000, floor(log($number, 1000))); $numBaseUnits = (int) ($number / $baseUnit); $remainder = $number % $baseUnit; $string = $this->convert_number_to_words($numBaseUnits) . ' ' . $dictionary[$baseUnit]; if ($remainder) { $string .= $remainder < 100 ? $conjunction : $separator; $string .= $this->convert_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 $string; }
/** * wcj_order_total_in_words. */ function wcj_order_total_in_words($atts) { $order_total = true === $atts['excl_tax'] ? $this->the_order->get_total() - $this->the_order->get_total_tax() : $this->the_order->get_total(); $order_total_dollars = intval($order_total); $order_total_cents = ($order_total - intval($order_total)) * 100; $the_number_in_words = '%s %s'; if (0 != $order_total_cents) { $the_number_in_words .= ', %s %s.'; } else { $the_number_in_words .= '.'; } $dollars = 'Dollars'; //$this->the_order->get_order_currency(); $cents = 'Cents'; return sprintf($the_number_in_words, ucfirst(convert_number_to_words($order_total_dollars)), $dollars, ucfirst(convert_number_to_words($order_total_cents)), $cents); }
echo number_format($row->price * $row->quantity); ?> VND </div> </td> </tr> <?php } ?> <tr> <td colspan="4" style="padding-left: 10px;text-align: left;"> Cộng thành tiền (viết bằng chữ)<br /> <strong><?php echo convert_number_to_words(abs((int) $cart->total - (int) $cart->prePaid)); ?> đồng.</strong> </td> <td style="padding-right: 10px;text-align: right;">Tổng cộng</td> <td style="padding-right: 10px;text-align: right;"> <div><?php echo number_format($cart->total); ?> VND</div></td> </tr> </table> </div>
Total : <div align="right"> </div> </td> <td width="100"> USD <input type='text' name='total' id="total" value="<?php echo $cmpnm[grand_total]; ?> " readonly=""/> </td> </tr> <tr> <td style="border:hidden;" width="20"> </td> <td colspan="6"> Order Value (in words):- <h4><?php echo convert_number_to_words($cmpnm['grand_total']); ?> </h4> <h4><div id='word'></div></h4> </td> </tr> </table>