本文整理汇总了PHP中NumberFormatter::getPattern方法的典型用法代码示例。如果您正苦于以下问题:PHP NumberFormatter::getPattern方法的具体用法?PHP NumberFormatter::getPattern怎么用?PHP NumberFormatter::getPattern使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NumberFormatter
的用法示例。
在下文中一共展示了NumberFormatter::getPattern方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: currency_side
function currency_side()
{
$config = get_instance()->config;
$fmt = new \NumberFormatter($config->item('number_locale'), \NumberFormatter::CURRENCY);
$fmt->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, $config->item('currency_symbol'));
return !preg_match('/^¤/', $fmt->getPattern());
}
示例2: moneda
public static function moneda($entero, $localidad = null, $codigo = null)
{
if (empty($entero)) {
return $entero;
}
$localidad = empty($localidad) ? self::LOCALIDAD_RD : $localidad;
$codigo = empty($codigo) ? self::CODIGO_RD : $codigo;
$sufijo = $localidad == 'es_DO' ? 'RD' : '';
$fmt = new NumberFormatter($localidad, NumberFormatter::CURRENCY);
//$fmt->setTextAttribute(NumberFormatter::CURRENCY_CODE, 'DOP');
$fmt->setPattern(str_replace('¤#', '¤ #', $fmt->getPattern()));
return $sufijo . $fmt->formatCurrency($entero, $codigo);
//setlocale(LC_MONETARY, $localidad);
//return money_format('%i', $entero) . "\n";
}
示例3: getPattern
/**
* Pattern espositivo della valuta
*
* @return bool|string
*/
public function getPattern()
{
$nft = new NF($this->locale, NF::CURRENCY);
return $nft->getPattern();
}
示例4: nReal
/**
* Mostra o Valor no real Formatado
* @param float $number
* @param boolean $fixed
* @param boolean $symbol
* @param integer $decimals
* @return string
*/
public static function nReal($number, $decimals = 2, $symbol = true, $fixed = true)
{
if (is_null($number) || empty(self::onlyNumbers($number))) {
return '';
}
$formater = new \NumberFormatter("pt-BR", \NumberFormatter::CURRENCY);
$formater->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, $fixed ? $decimals : 1);
if ($decimals === false) {
$decimals = 2;
preg_match_all('/[0-9][^0-9]([0-9]+)/', $number, $matches);
if (!empty($matches[1])) {
$decimals = strlen(rtrim($matches[1][0], 0));
}
}
$formater->setAttribute(\NumberFormatter::MAX_FRACTION_DIGITS, $decimals);
if (!$symbol) {
$pattern = preg_replace("/[¤]/", '', $formater->getPattern());
$formater->setPattern($pattern);
} else {
// ESPAÇO DEPOIS DO SIMBOLO
$pattern = str_replace("¤", "¤ ", $formater->getPattern());
$formater->setPattern($pattern);
}
return $formater->formatCurrency($number, $formater->getTextAttribute(\NumberFormatter::CURRENCY_CODE));
}