当前位置: 首页>>代码示例>>PHP>>正文


PHP money_format函数代码示例

本文整理汇总了PHP中money_format函数的典型用法代码示例。如果您正苦于以下问题:PHP money_format函数的具体用法?PHP money_format怎么用?PHP money_format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了money_format函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: format

 /**
  * format a monetary string
  *
  * Format a monetary string basing on the amount provided,
  * ISO currency code provided and a format string consisting of:
  *
  * %a - the formatted amount
  * %C - the currency ISO code (e.g., 'USD') if provided
  * %c - the currency symbol (e.g., '$') if available
  *
  * @param float  $amount    the monetary amount to display (1234.56)
  * @param string $currency  the three-letter ISO currency code ('USD')
  * @param string $format    the desired currency format
  *
  * @return string  formatted monetary string
  *
  * @static
  */
 static function format($amount, $currency = null, $format = null)
 {
     if (CRM_Utils_System::isNull($amount)) {
         return '';
     }
     $config =& CRM_Core_Config::singleton();
     if (!self::$_currencySymbols) {
         require_once "CRM/Core/PseudoConstant.php";
         $currencySymbolName = CRM_Core_PseudoConstant::currencySymbols('name');
         $currencySymbol = CRM_Core_PseudoConstant::currencySymbols();
         self::$_currencySymbols = array_combine($currencySymbolName, $currencySymbol);
     }
     if (!$currency) {
         $currency = $config->defaultCurrency;
     }
     if (!$format) {
         $format = $config->moneyformat;
     }
     // money_format() exists only in certain PHP install (CRM-650)
     if (is_numeric($amount) and function_exists('money_format')) {
         $amount = money_format($config->moneyvalueformat, $amount);
     }
     $replacements = array('%a' => $amount, '%C' => $currency, '%c' => CRM_Utils_Array::value($currency, self::$_currencySymbols, $currency));
     return strtr($format, $replacements);
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:43,代码来源:Money.php

示例2: showContent

	/**
	 * @see	Site::show()
	 */
	public function showContent() {
		$artArray = array();

		foreach ( $this->digitalArtIterator as $digitalArt ) {
			$artName = $digitalArt->getDigitalArtName();
			$artItem  = '<dl>';
			$artItem .= '<dt>' . $artName . '</dt>';
			$artItem .= sprintf( '<dd><img alt="%s" src="%s" width="100" height="100" /></dd>',
				$artName,
				$digitalArt->getDigitalArtMedia()
			);

			$artItem .= '<dd class="by-price"><span class="by">by ' . $digitalArt->getAuthor()->getAuthorName() . '</span>';
			$artItem .= '<span class="price">R$ ' . money_format( '%.02n' , $digitalArt->getDigitalArtPrice() ) . '</span></dd>';
			$artItem .= sprintf( '<dd class="buy"><a class="buy" href="index.php?action=buy&idDigitalArt=%d">Comprar</a></dd>',
				$digitalArt->getIdDigitalArt()
			);

			$artItem .= '</dl>';

			$artArray[] = $artItem;
		}

		if ( count( $artArray ) > 0 ) {
			$content = sprintf( '<ul><li>%s</li></ul>' , implode( '</li><li>' , $artArray ) );
		} else {
			$content = '<strong>Nenhuma arte encontrada</strong>';
		}

		echo '<h2>Arte Digital</h2>' , $content;
	}
开发者ID:netojoaobatista,项目名称:paypal-express-checkout-dg,代码行数:34,代码来源:HomeView.php

示例3: my_money_format

 public static function my_money_format($number)
 {
     if (function_exists('money_format')) {
         return money_format("%i", $number);
     }
     return $number;
 }
开发者ID:kienbk1910,项目名称:RDCAdmin,代码行数:7,代码来源:StringUtility.php

示例4: smarty_modifier_money_format

function smarty_modifier_money_format($num, $format = "%n", $locale = null)
{
    $curr = false;
    $savelocale = null;
    $savelocale = setlocale(LC_MONETARY, null);
    // use en_US if current locale is unrecognized
    if ((!isset($locale) || $locale == '') && ($savelocale == '' || $savelocale == 'C')) {
        $locale = 'en_US';
    }
    if (isset($locale) && $locale != '') {
        setlocale(LC_MONETARY, $locale);
    }
    if (function_exists('money_format')) {
        $curr = money_format($format, $num);
    } else {
        // function would be available in PHP 4.3
        //return $num . ' (money_format would be available in PHP 4.3)';
        //if not PHP 4.3 , using number format
        $curr = number_format($num, 0, '.', ',');
    }
    if (isset($locale) && $locale != '') {
        setlocale(LC_MONETARY, $savelocale);
    }
    $curr = trim($curr);
    return $curr;
}
开发者ID:tuyenv,项目名称:litpi-framework-3,代码行数:26,代码来源:modifier.money_format.php

示例5: __construct

 /**
  * @param	Product $product
  * @param	integer $qtd
  */
 public function __construct(Product $product, $qtd)
 {
     parent::__construct();
     $resourceBundle = Application::getInstance()->getBundle();
     $idProduct = $product->getIdProduct();
     $moneyformat = $resourceBundle->getString('MONEY_FORMAT');
     $productName = $product->getProductName();
     $productDescription = $product->getProductDescription();
     $productPrice = $product->getProductPrice();
     $form = $this->addChild(new Form('/?c=cart&a=change&p=' . $idProduct));
     //Imagem do produto
     $form->addChild(new Image($product->getProductImage(), $productName))->setTitle($productName)->setAttribute('width', 80)->setAttribute('height', 80);
     //Nome e descrição do produto
     $form->addChild(new Span())->addStyle('name')->addChild(new Text($productName));
     $form->addChild(new Span())->addStyle('desc')->addChild(new Text($productDescription));
     //Input com a quantidade de itens
     $form->addChild(new Label(new Text($resourceBundle->getString('QUANTITY'))))->addChild(new Input('qtd'))->setValue($qtd);
     //Preço unitário
     $form->addChild(new Span())->addStyle('price')->addChild(new Text(money_format($moneyformat, $productPrice)));
     //Preço total
     $form->addChild(new Span())->addStyle('total')->addChild(new Text(money_format($moneyformat, $qtd * $productPrice)));
     //Botões para edição e exclusão do item do carrinho
     $form->addChild(new Input('save', Input::SUBMIT))->setValue($resourceBundle->getString('SAVE'));
     $form->addChild(new Input('del', Input::SUBMIT))->setValue($resourceBundle->getString('DELETE'));
 }
开发者ID:rcastardo,项目名称:mvc-na-pratica,代码行数:29,代码来源:CartItem.php

示例6: format

 /**
  * format a monetary string
  *
  * Format a monetary string basing on the amount provided,
  * ISO currency code provided and a format string consisting of:
  *
  * %a - the formatted amount
  * %C - the currency ISO code (e.g., 'USD') if provided
  * %c - the currency symbol (e.g., '$') if available
  *
  * @param float  $amount    the monetary amount to display (1234.56)
  * @param string $currency  the three-letter ISO currency code ('USD')
  * @param string $format    the desired currency format
  *
  * @return string  formatted monetary string
  *
  * @static
  */
 function format($amount, $currency = null, $format = null)
 {
     if (CRM_Utils_System::isNull($amount)) {
         return '';
     }
     if (!$GLOBALS['_CRM_UTILS_MONEY']['currencySymbols']) {
         $GLOBALS['_CRM_UTILS_MONEY']['currencySymbols'] = array('EUR' => '€', 'GBP' => '£', 'ILS' => '₪', 'JPY' => '¥', 'KRW' => '₩', 'LAK' => '₭', 'MNT' => '₮', 'NGN' => '₦', 'PLN' => 'zł', 'THB' => '฿', 'USD' => '$', 'VND' => '₫');
     }
     if (!$currency) {
         if (!$GLOBALS['_CRM_UTILS_MONEY']['config']) {
             $GLOBALS['_CRM_UTILS_MONEY']['config'] =& CRM_Core_Config::singleton();
         }
         $currency = $GLOBALS['_CRM_UTILS_MONEY']['config']->defaultCurrency;
     }
     if (!$format) {
         if (!$GLOBALS['_CRM_UTILS_MONEY']['config']) {
             $GLOBALS['_CRM_UTILS_MONEY']['config'] =& CRM_Core_Config::singleton();
         }
         $format = $GLOBALS['_CRM_UTILS_MONEY']['config']->moneyformat;
     }
     $money = $amount;
     // this function exists only in certain php install (CRM-650)
     if (function_exists('money_format')) {
         $money = money_format('%!i', $amount);
     }
     $replacements = array('%a' => $money, '%C' => $currency, '%c' => CRM_Utils_Array::value($currency, $GLOBALS['_CRM_UTILS_MONEY']['currencySymbols'], $currency));
     return strtr($format, $replacements);
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:46,代码来源:Money.php

示例7: chargeIt

 /** ============================================================================================================
  * Take the money from over there, and put it over here
  * @param  array $merchant 				CamelCased model name One of the merchant_ models in the DoughKit plugin (without "merchant_")
  * @param  array $transactionDetails 	An array of transaction details
  * @return array $response 				An array of the response!
  */
 function chargeIt($merchant = null, $transactionDetails = array())
 {
     if (!$merchant || empty($transactionDetails)) {
         return false;
     }
     $Merchant = ClassRegistry::init('C7DoughKit.Merchant' . $merchant);
     $this->transactionDetails = array_merge($this->transactionDetails, $transactionDetails);
     // Do some cleanup/validation on the $transactionDetails fields
     $this->transactionDetails['amount_to_charge'] = is_numeric(money_format($this->transactionDetails['amount_to_charge'], 2)) ? money_format($this->transactionDetails['amount_to_charge'], 2) : 0;
     $this->transactionDetails['card_number'] = preg_replace("/[^0-9 ]/", '', $this->transactionDetails['card_number']);
     $this->transactionDetails['card_exp_month'] = preg_replace("/[^0-9 ]/", '', $this->transactionDetails['card_exp_month']);
     $this->transactionDetails['card_exp_year'] = preg_replace("/[^0-9 ]/", '', $this->transactionDetails['card_exp_year']);
     if ($this->transactionDetails['amount_to_charge'] > 0 && !empty($this->transactionDetails['card_number']) && !empty($this->transactionDetails['card_exp_month']) && !empty($this->transactionDetails['card_exp_year'])) {
         $response = $Merchant->chargeIt($this->transactionDetails);
         // Address Verification System Response Code Description
         $AddressVerificationServiceCode = ClassRegistry::init('C7DoughKit.AddressVerificationServiceCode');
         $response['avs_response_description'] = isset($response['avs_response_code']) ? $AddressVerificationServiceCode->getCodeDescription($response['avs_response_code']) : '';
         // CVV2 Response Code Description
         $CardVerificationValueResponseCode = ClassRegistry::init('C7DoughKit.CardVerificationValueResponseCode');
         $response['cvv_verification_response_description'] = isset($response['cvv_verification_response_code']) ? $CardVerificationValueResponseCode->getCodeDescription($response['cvv_verification_response_code']) : '';
         // die(debug($response));
         return $response;
     }
     return false;
 }
开发者ID:CoalesceDesign,项目名称:cakephp,代码行数:31,代码来源:c7_dough_kit.php

示例8: getMoneyAttribute

 public function getMoneyAttribute()
 {
     setlocale(LC_MONETARY, "vi_VN");
     $money = money_format('%i ', (double) $this->getAttribute('money'));
     $money = str_replace('VND', ' VND', $money);
     return $money;
 }
开发者ID:httvncoder,项目名称:151722441,代码行数:7,代码来源:Money.php

示例9: donation

 /**
  *   Process the donation
  *
  *   @param Request $request
  *
  *   @return json response
  */
 public function donation(Request $request)
 {
     try {
         $charge = Stripe::charges()->create(['currency' => 'CAD', 'amount' => money_format("%i", $request->amount / 100), 'source' => $request->token]);
         // TODO: Do this better.
     } catch (\Cartalyst\Stripe\Exception\BadRequestException $e) {
         return response()->json(['success' => false]);
     } catch (\Cartalyst\Stripe\Exception\UnauthorizedException $e) {
         return response()->json(['success' => false]);
     } catch (\Cartalyst\Stripe\Exception\InvalidRequestException $e) {
         return response()->json(['success' => false]);
     } catch (\Cartalyst\Stripe\Exception\NotFoundException $e) {
         return response()->json(['success' => false]);
     } catch (\Cartalyst\Stripe\Exception\CardErrorException $e) {
         return response()->json(['success' => false]);
     } catch (\Cartalyst\Stripe\Exception\ServerErrorException $e) {
         return response()->json(['success' => false]);
     }
     if ($request->user()) {
         $request->user()->donations()->create(['stripe_token' => $charge['id'], 'amount' => $request->amount]);
     } else {
         /**
          *   The user is not logged in, so here we are creating an anonymous donation in the database
          *   It is not associated with a user id
          */
         $donation = new Donation();
         $donation->email = $request->email;
         $donation->stripe_token = $charge['id'];
         $donation->amount = $request->amount;
         $donation->save();
     }
     return response()->json(['success' => true]);
 }
开发者ID:BrantWladichuk,项目名称:gamechalleng.es,代码行数:40,代码来源:PaymentController.php

示例10: smarty_money_format

function smarty_money_format($params, &$smarty)
{
    if (empty($params['price'])) {
        $params['price'] = 0;
    }
    return money_format('%.2n', $params['price']);
}
开发者ID:lopacinski,项目名称:WebFinance,代码行数:7,代码来源:smarty.php

示例11: apply

 /**
  * Apply format to argument
  *
  * @param   var fmt
  * @param   var argument
  * @return  string
  */
 public function apply($fmt, $argument)
 {
     if (!function_exists('money_format')) {
         throw new FormatException('money_format requires PHP >= 4.3.0');
     }
     return money_format($fmt, $argument);
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:14,代码来源:MoneyFormat.class.php

示例12: selectProduct

 public function selectProduct($product)
 {
     $productPrice = $this->products[$product]['price'];
     // What do we display if no money is inserted?
     if ($this->currentAmount == 0) {
         if ($this->products[$product]['inventory'] == 0) {
             $this->display = "SOLD OUT";
         } else {
             $displayAmount = $this->products[$product]['price'] / 100;
             $this->display = "PRICE " . money_format("%.2n", $displayAmount);
         }
     }
     // Enough money has been inserted for the selected product
     if ($this->currentAmount >= $productPrice) {
         if ($this->products[$product]['inventory'] == 0) {
             $this->display = "SOLD OUT";
         } else {
             $this->display = 'THANK YOU';
             $this->productDispensed = true;
             $this->products[$product]['inventory'] -= 1;
             foreach ($this->coins as $type => $qty) {
                 $this->bank[$type] += $qty;
             }
             $overPayment = $this->currentAmount - $productPrice;
         }
     }
     // Do we owe the customer change?
     if ($overPayment > 0) {
         $this->makeChange($overPayment);
     }
 }
开发者ID:heidilux,项目名称:kata-vending-machine,代码行数:31,代码来源:VendingMachine.php

示例13: PriceTable

 function PriceTable($cart, $total)
 {
     setlocale(LC_MONETARY, 'th_TH');
     $this->SetFont('Arial', 'B', 10);
     $this->SetTextColor(0);
     $this->SetFillColor(36, 140, 129);
     $this->SetLineWidth(1);
     $this->Cell(45, 25, "Quantity", 'LTR', 0, 'C', true);
     $this->Cell(260, 25, "Item Description", 'LTR', 0, 'C', true);
     $this->Cell(85, 25, "Price", 'LTR', 0, 'C', true);
     $this->Cell(85, 25, "Sub-Total", 'LTR', 1, 'C', true);
     $this->SetFont('Arial', '');
     $this->SetFillColor(238);
     $this->SetLineWidth(0.2);
     $fill = false;
     foreach ($cart as $cartItem) {
         $this->Cell(45, 20, $cartItem['quantity'], 1, 0, 'L', $fill);
         $this->Cell(260, 20, $cartItem['name'], 1, 0, 'L', $fill);
         $this->Cell(85, 20, money_format("%i", $cartItem['price']), 1, 0, 'R', $fill);
         $this->Cell(85, 20, money_format("%i", $cartItem['subtotal']), 1, 1, 'R', $fill);
         $fill = !$fill;
     }
     $this->SetX(305 + 40);
     $this->Cell(85, 20, "Total", 1);
     $this->Cell(85, 20, money_format("%i", $total) . ' Baht', 1, 1, 'R');
 }
开发者ID:sunny36,项目名称:grecocos,代码行数:26,代码来源:pdf.php

示例14: outputPdf

 protected function outputPdf()
 {
     $assistantsCost = filter_input(INPUT_GET, 'assistantsCost');
     $toolsCost = filter_input(INPUT_GET, 'toolsCost');
     if (isset($assistantsCost)) {
         $assistantsCost = str_replace(',', '.', $assistantsCost);
         $assistantsCost = money_format('%.2n', floatval($assistantsCost));
     }
     if (isset($toolsCost)) {
         $toolsCost = str_replace(',', '.', $toolsCost);
         $toolsCost = money_format('%.2n', floatval($toolsCost));
     }
     $otherCosts = [];
     if (isset($_GET['otherCosts']) && count($_GET['otherCosts'])) {
         $otherCosts = $_GET['otherCosts'];
         $otherCosts = array_map(function ($otherCost) {
             $date = date('d.m.Y', strtotime($otherCost['date']));
             $amount = money_format('%.2n', floatval($otherCost['amount']));
             return ['amount' => $amount, 'date' => $date, 'recipient' => $otherCost['recipient']];
         }, $_GET['otherCosts']);
     }
     $data = $this->calculateData();
     $today = date('d.m.Y H:i');
     $title = "Schbas Statistik ({$today})";
     $this->_smarty->assign('data', $data);
     $this->_smarty->assign('assistantsCost', $assistantsCost);
     $this->_smarty->assign('toolsCost', $toolsCost);
     $this->_smarty->assign('otherCosts', $otherCosts);
     $this->_smarty->assign('title', $title);
     $pdf = new GeneralPdf($this->_pdo);
     $html = $this->_smarty->fetch(PATH_SMARTY_TPL . '/pdf/schbas-statistics.pdf.tpl');
     $pdf->create($title, $html);
     $pdf->output();
 }
开发者ID:Auwibana,项目名称:babesk,代码行数:34,代码来源:SchbasStatistics.php

示例15: smarty_function_money_format

function smarty_function_money_format($params, &$smarty)
{
    if (!isset($params['value'])) {
        show_error('You must pass a "value" to the {money_format} template function.');
    }
    return money_format("%!^i", $params['value']);
}
开发者ID:jnavarroc,项目名称:hero,代码行数:7,代码来源:function.money_format.php


注:本文中的money_format函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。