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


PHP CRM_Utils_Money::_currencySymbols方法代码示例

本文整理汇总了PHP中CRM_Utils_Money::_currencySymbols方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Money::_currencySymbols方法的具体用法?PHP CRM_Utils_Money::_currencySymbols怎么用?PHP CRM_Utils_Money::_currencySymbols使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Utils_Money的用法示例。


在下文中一共展示了CRM_Utils_Money::_currencySymbols方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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, $onlyNumber = FALSE)
 {
     if (CRM_Utils_System::isNull($amount)) {
         return '';
     }
     $config = CRM_Core_Config::singleton();
     if (!$format) {
         $format = $config->moneyformat;
     }
     if ($onlyNumber) {
         // 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);
         }
         return $amount;
     }
     if (!self::$_currencySymbols) {
         $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)
     // setlocale() affects native gettext (CRM-11054, CRM-9976)
     if (is_numeric($amount) && function_exists('money_format')) {
         $lc = setlocale(LC_MONETARY, 0);
         setlocale(LC_MONETARY, 'en_US.utf8', 'en_US', 'en_US.utf8', 'en_US', 'C');
         $amount = money_format($config->moneyvalueformat, $amount);
         setlocale(LC_MONETARY, $lc);
     }
     $rep = array(',' => $config->monetaryThousandSeparator, '.' => $config->monetaryDecimalPoint);
     // If it contains tags, means that HTML was passed and the
     // amount is already converted properly,
     // so don't mess with it again.
     if (strip_tags($amount) === $amount) {
         $money = strtr($amount, $rep);
     } else {
         $money = $amount;
     }
     $replacements = array('%a' => $money, '%C' => $currency, '%c' => CRM_Utils_Array::value($currency, self::$_currencySymbols, $currency));
     return strtr($format, $replacements);
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:65,代码来源:Money.php


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