本文整理汇总了PHP中convert_number_to_words函数的典型用法代码示例。如果您正苦于以下问题:PHP convert_number_to_words函数的具体用法?PHP convert_number_to_words怎么用?PHP convert_number_to_words使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了convert_number_to_words函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convert_number_to_words
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;
}
示例2: country_currency
<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
示例3: convert_number_to_words
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;
}
示例4: payment_amount
/**
* @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'];
}
示例5: nl2br
</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>
示例6: sprintf
</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>
示例7: wcj_order_total_in_words
/**
* 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);
}
示例8: explode
<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>
示例9: convert_number_to_words
</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>
示例10: convert_number_to_words
<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'];
?>
示例11: convert_number_to_words
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;
}
示例12: convert_number_to_word_month
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;
}
示例13: convert_number_to_words
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);
}
示例14: convert_number_to_words
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;
}
示例15: wcj_order_total_in_words
/**
* 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);
}
}