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


PHP localeconv函数代码示例

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


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

示例1: process

 public function process($value, array $params = array())
 {
     $locale = localeconv();
     $wrapperTpl = isset($params['wrapperTpl']) ? $params['wrapperTpl'] : null;
     $pointTpl = isset($params['pointTpl']) ? $params['pointTpl'] : null;
     $pointSep = isset($params['pointSep']) ? $params['pointSep'] : '';
     $decimalSep = isset($params['decimalSep']) ? $params['decimalSep'] : $locale['decimal_point'];
     $data = json_decode($value);
     $points = array();
     if (is_object($data) && isset($data->points)) {
         foreach ($data->points as $point) {
             $latitude = number_format($point->lat, 8, $decimalSep, '');
             $longitude = number_format($point->lng, 8, $decimalSep, '');
             if ($pointTpl) {
                 $points[] = $this->modx->getChunk($pointTpl, array('latitude' => $latitude, 'longitude' => $longitude));
             } else {
                 $points[] = $latitude . $longitude;
             }
         }
         $pointsString = implode($pointSep, $points);
         if ($wrapperTpl) {
             $output = $this->modx->getChunk($wrapperTpl, array('points' => $pointsString));
         } else {
             $output = $pointsString;
         }
         return $output;
     }
 }
开发者ID:Spheerys,项目名称:geotv,代码行数:28,代码来源:geotv_geopoint.class.php

示例2: validate

 /**
  * {@inheritdoc}
  *
  * @param  \Phalcon\Mvc\EntityInterface $record
  * @return boolean
  * @throws \Phalcon\Mvc\Model\Exception
  */
 public function validate(EntityInterface $record)
 {
     $field = $this->getOption('field');
     if (false === is_string($field)) {
         throw new Exception('Field name must be a string');
     }
     $value = $record->readAttribute($field);
     if (true === $this->isSetOption('allowEmpty') && empty($value)) {
         return true;
     }
     if (false === $this->isSetOption('places')) {
         throw new Exception('A number of decimal places must be set');
     }
     if ($this->isSetOption('digits')) {
         // Specific number of digits
         $digits = '{' . (int) $this->getOption('digits') . '}';
     } else {
         // Any number of digits
         $digits = '+';
     }
     if ($this->isSetOption('point')) {
         $decimal = $this->getOption('point');
     } else {
         // Get the decimal point for the current locale
         list($decimal) = array_values(localeconv());
     }
     $result = (bool) preg_match(sprintf('#^[+-]?[0-9]%s%s[0-9]{%d}$#', $digits, preg_quote($decimal), $this->getOption('places')), $value);
     if (!$result) {
         // Check if the developer has defined a custom message
         $message = $this->getOption('message') ?: sprintf('%s must contain valid decimal value', $field);
         $this->appendMessage($message, $field, 'Decimal');
         return false;
     }
     return true;
 }
开发者ID:lisong,项目名称:incubator,代码行数:42,代码来源:Decimal.php

示例3: getLocaleParams

 /**
  * @param bool $reload
  * @return array
  */
 public function getLocaleParams($reload = false)
 {
     if (null === $this->localeParams || $reload) {
         $this->localeParams = localeconv();
     }
     return $this->localeParams;
 }
开发者ID:rakorium,项目名称:okapi,代码行数:11,代码来源:Number.php

示例4: getDefaultFormatter

 /**
  * @return FormatterInterface
  */
 private function getDefaultFormatter()
 {
     $locale = localeconv();
     $formatter = new StandardFormatter();
     $formatter->setDecimalSeperator($locale['decimal_point']);
     return $formatter;
 }
开发者ID:ayeo,项目名称:temperature,代码行数:10,代码来源:DefaultFactory.php

示例5: Currency_USD

 function Currency_USD()
 {
     $this->lang = "English [en]";
     if (setlocale(LC_MONETARY, 'en_US') !== false && setlocale(LC_NUMERIC, 'en_US') !== false) {
         $this->locale = localeconv();
     }
 }
开发者ID:nateirwin,项目名称:custom-historic,代码行数:7,代码来源:Currency_USD.php

示例6: windowsSafeMoneyFormat

 /**
  * Windows-compatible equivalent to built-in money_format function.
  *
  * @param string $number Number to format.
  *
  * @return string
  */
 public static function windowsSafeMoneyFormat($number)
 {
     // '' or NULL gets the locale values from environment variables
     setlocale(LC_ALL, '');
     $locale = localeconv();
     extract($locale);
     // Windows doesn't support UTF-8 encoding in setlocale, so we'll have to
     // convert the currency symbol manually:
     $currency_symbol = self::safeMoneyFormatMakeUTF8($currency_symbol);
     // How is the amount signed?
     // Positive
     if ($number > 0) {
         $sign = $positive_sign;
         $sign_posn = $p_sign_posn;
         $sep_by_space = $p_sep_by_space;
         $cs_precedes = $p_cs_precedes;
     } else {
         // Negative
         $sign = $negative_sign;
         $sign_posn = $n_sign_posn;
         $sep_by_space = $n_sep_by_space;
         $cs_precedes = $n_cs_precedes;
     }
     // Format the absolute value of the number
     $m = number_format(abs($number), $frac_digits, $mon_decimal_point, $mon_thousands_sep);
     // Spaces between the number and symbol?
     if ($sep_by_space) {
         $space = ' ';
     } else {
         $space = '';
     }
     if ($cs_precedes) {
         $m = $currency_symbol . $space . $m;
     } else {
         $m = $m . $space . $currency_symbol;
     }
     // HTML spaces
     $m = str_replace(' ', ' ', $m);
     // Add symbol
     switch ($sign_posn) {
         case 0:
             $m = "({$m})";
             break;
         case 1:
             $m = $sign . $m;
             break;
         case 2:
             $m = $m . $sign;
             break;
         case 3:
             $m = $sign . $m;
             break;
         case 4:
             $m = $m . $sign;
             break;
         default:
             $m = "{$m} [error sign_posn = {$sign_posn} !]";
     }
     return $m;
 }
开发者ID:no-reply,项目名称:cbpl-vufind,代码行数:67,代码来源:SafeMoneyFormat.php

示例7: isValid

 /**
  * Defined by Zend_Validate_Interface
  *
  * Returns true if and only if $value is a valid integer
  *
  * @param  string|integer $value
  * @return boolean
  */
 public function isValid($value)
 {
     if (!is_string($value) && !is_int($value) && !is_float($value)) {
         $this->error(self::INVALID);
         return false;
     }
     if (is_int($value)) {
         return true;
     }
     $this->setValue($value);
     if ($this->locale === null) {
         $locale = localeconv();
         $valueFiltered = str_replace($locale['decimal_point'], '.', $value);
         $valueFiltered = str_replace($locale['thousands_sep'], '', $valueFiltered);
         if (strval(intval($valueFiltered)) != $valueFiltered) {
             $this->error(self::NOT_INT);
             return false;
         }
     } else {
         try {
             if (!Zend_Locale_Format::isInteger($value, ['locale' => $this->locale])) {
                 $this->error(self::NOT_INT);
                 return false;
             }
         } catch (Zend_Locale_Exception $e) {
             $this->error(self::NOT_INT);
             return false;
         }
     }
     return true;
 }
开发者ID:argentinaluiz,项目名称:js_zf2_library,代码行数:39,代码来源:JSInt.php

示例8: numeric_variable

 /**
  * Checks whether a string is a valid number with optional prefix ~, + or -.
  * Allow only EN . delimiter
  * 
  * @param   string  $str    input string
  * @return  boolean
  */
 public static function numeric_variable($str)
 {
     // Get the decimal point for the current locale
     list($decimal) = array_values(localeconv());
     // A lookahead is used to make sure the string contains at least one digit (before or after the decimal point)
     return (bool) preg_match('/^[~\\+-]?\\d*\\.?\\d*$/', (string) $str);
 }
开发者ID:steffomix,项目名称:isim-beo,代码行数:14,代码来源:Valid.php

示例9: validate

 /**
  * {@inheritdoc}
  *
  * @param Validation $validation
  * @param string $attribute
  *
  * @return bool
  * @throws Exception
  */
 public function validate(Validation $validation, $attribute)
 {
     $value = $validation->getValue($attribute);
     $field = $this->getOption('label');
     if (empty($field)) {
         $validation->getLabel($attribute);
     }
     if (false === $this->hasOption('places')) {
         throw new Exception('A number of decimal places must be set');
     }
     if ($this->hasOption('digits')) {
         // Specific number of digits
         $digits = '{' . (int) $this->getOption('digits') . '}';
     } else {
         // Any number of digits
         $digits = '+';
     }
     if ($this->hasOption('point')) {
         $decimal = $this->getOption('point');
     } else {
         // Get the decimal point for the current locale
         list($decimal) = array_values(localeconv());
     }
     $result = (bool) preg_match(sprintf('#^[+-]?[0-9]%s%s[0-9]{%d}$#', $digits, preg_quote($decimal), $this->getOption('places')), $value);
     if (!$result) {
         $message = $this->getOption('message');
         $replacePairs = [':field' => $field];
         if (empty($message)) {
             $message = ':field must contain valid decimal value';
         }
         $validation->appendMessage(new Message(strtr($message, $replacePairs), $attribute, 'Decimal'));
         return false;
     }
     return true;
 }
开发者ID:phalcon,项目名称:incubator,代码行数:44,代码来源:Decimal.php

示例10: ParseFloat

function ParseFloat($floatString)
{
    $LocaleInfo = localeconv();
    $floatString = str_replace(".", "", $floatString);
    $floatString = str_replace(",", ".", $floatString);
    return floatval($floatString);
}
开发者ID:workcrm,项目名称:consoli,代码行数:7,代码来源:ModuloRetornoVisualiza.php

示例11: setup

 /**
  * Adjust configs like: $Model->Behaviors-attach('Tools.DecimalInput', array('fields'=>array('xyz')))
  * leave fields empty to auto-detect all float inputs
  *
  * @return void
  */
 public function setup(Model $Model, $config = array())
 {
     $this->settings[$Model->alias] = $this->_defaultConfig;
     if (!empty($config['strict'])) {
         $this->settings[$Model->alias]['transform']['.'] = '#';
     }
     if ($this->settings[$Model->alias]['localeconv'] || !empty($config['localeconv'])) {
         // use locale settings
         $conv = localeconv();
         $loc = array('decimals' => $conv['decimal_point'], 'thousands' => $conv['thousands_sep']);
     } elseif ($configure = Configure::read('Localization')) {
         // Use configure settings
         $loc = (array) $configure;
     }
     if (!empty($loc)) {
         $this->settings[$Model->alias]['transform'] = array($loc['thousands'] => $this->settings[$Model->alias]['transform']['.'], $loc['decimals'] => $this->settings[$Model->alias]['transform'][',']);
     }
     $this->settings[$Model->alias] = $config + $this->settings[$Model->alias];
     $numberFields = array();
     $schema = $Model->schema();
     foreach ($schema as $key => $values) {
         if (isset($values['type']) && !in_array($key, $this->settings[$Model->alias]['fields']) && in_array($values['type'], $this->settings[$Model->alias]['observedTypes'])) {
             array_push($numberFields, $key);
         }
     }
     $this->settings[$Model->alias]['fields'] = array_merge($this->settings[$Model->alias]['fields'], $numberFields);
 }
开发者ID:Jony01,项目名称:LLD,代码行数:33,代码来源:DecimalInputBehavior.php

示例12: __construct

 public function __construct($locale, $style, $format)
 {
     $lsave = setlocale(LC_ALL, "0");
     $this->def_first_group = 3;
     $this->decimal_sep = '.';
     $this->group_sep = ',';
     $this->exponent_string = "E";
     $this->negative_prefix = "-";
     $this->positive_prefix = "+";
     $loc = setlocale(LC_ALL, $locale);
     if ($loc) {
         $info = localeconv();
         $this->decimal_sep = $info['decimal_point'];
         $this->group_sep = $info['thousands_sep'];
         // $this->negative_prefix = $info['negative_sign'];
         // $this->positive_prefix = $info['positive_sign'];
         setlocale(LC_ALL, $lsave);
     }
     $fmts = explode(";", $format);
     if (!isset($fmts[1])) {
         $fmts[1] = $this->negative_prefix . $fmts[0];
     }
     $neg = $this->parsefmt($fmts[1]);
     $this->pos_format = $this->parsefmt($fmts[0]);
     $neg2 = $this->pos_format;
     $neg2[0] = $neg[0];
     $neg2[3] = $neg[3];
     $this->neg_format = $neg2;
     // print_r($this);
 }
开发者ID:maduhu,项目名称:opengovplatform-beta,代码行数:30,代码来源:visformat.php

示例13: wpcf_field_number_validation_fix

/**
 * wpcf_field_number_validation_fix
 *
 * Fix JS validation for field:numeric. Allow comma validation 
 */
function wpcf_field_number_validation_fix()
{
    $locale = localeconv();
    if ($locale['decimal_point'] != '.') {
        wp_enqueue_script('wpcf-numeric', WPCF_EMBEDDED_RES_RELPATH . '/js/numeric_fix.js', array('jquery'), WPCF_VERSION);
    }
}
开发者ID:CrankMaster336,项目名称:FFW-TR,代码行数:12,代码来源:numeric.php

示例14: Sub

 public static function Sub($op1, $op2, $op3 = null)
 {
     print "\nSUB";
     print "\nLocale:" . setlocale(LC_ALL, 0);
     print "\nConv:";
     print_r(localeconv());
     print "\nOP1:{$op1}\nOP2:{$op2}\nOP3:{$op3}";
     if (empty($op1)) {
         $op1 = 0;
     }
     self::localize($op1);
     self::localize($op2);
     print "\nLO1:{$op1}\nLO2:{$op2}";
     $result = $op1 - $op2;
     print "\nRES:{$result}";
     print "\nSTR:" . (string) ($result + $op2);
     if ($result === INF or (string) ($result + $op2) != (string) $op1) {
         require_once 'Zend/Locale/Math/Exception.php';
         throw new Zend_Locale_Math_Exception("subtraction overflow: {$op1} - {$op2} != {$result}", $op1, $op2, $result);
     }
     if ($op3 === null) {
         $op3 = Zend_Locale_Math_PhpMath::$_scale;
     }
     return self::round($result, $op3);
 }
开发者ID:Tony133,项目名称:zf-web,代码行数:25,代码来源:PhpMath.php

示例15: format

 /**
 		Return ICU-formatted string
 			@return string
 			@param $str string
 			@param $args mixed
 			@public
 	**/
 static function format($str, $args)
 {
     // Format string according to locale rules
     if (extension_loaded('intl')) {
         return msgfmt_format_message(Locale::getDefault(), $str, is_array($args) ? $args : array($args));
     }
     $info = localeconv();
     return preg_replace_callback('/{(\\d+)(?:,(\\w+)(?:,(\\w+))?)?}/', function ($expr) use($args, $info) {
         $arg = $args[$expr[1]];
         if (!isset($expr[2])) {
             return $arg;
         }
         if ($expr[2] == 'number') {
             if (isset($expr[3])) {
                 switch ($expr[3]) {
                     case 'integer':
                         return number_format($arg, 0, $info['decimal_point'], $info['thousands_sep']);
                     case 'currency':
                         return $info['currency_symbol'] . ($info['p_sep_by_space'] ? ' ' : '') . number_format($arg, $info['frac_digits'], $info['mon_decimal_point'], $info['mon_thousands_sep']);
                 }
             } else {
                 return sprintf('%f', $arg);
             }
         } elseif ($expr[2] == 'date') {
             return strftime('%x', $arg);
         } else {
             return $arg;
         }
     }, $str);
 }
开发者ID:huckfinnaafb,项目名称:leviatha,代码行数:37,代码来源:icu.php


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