localeconv()

1. 定义

该函数返回一个包含当地数字与货币信息的数组。

注:

  • 该函数的返回数组中有以下 18 个元素:
    • decimal_point:小数点符号,默认为.
    • thousands_sep:千位分隔符
    • int_curr_symbol:国际货币符号
    • currency_symbol:当地货币符号
    • mon_decimal_point:货币小数点符号
    • mon_thousands_sep:货币千位分隔符
    • positive_sign:正数符号
    • negative_sign:负数符号
    • int_frac_digits:国际通用小数位数,默认为2
    • frac_digits:当地通用小数位数
    • p_cs_precedes:货币符号在正数值之前显示则返回TRUE,否则返回FALSE
    • p_sep_by_space:货币符号和正数值之间含有空格则返回TRUE,否则返回FALSE
    • n_cs_precedes:货币符号在负数值之前显示则返回TRUE,否则返回FALSE
    • n_sep_by_space:货币符号和负数值之间含有空格则返回TRUE,否则返回FALSE
    • p_sign_posn:正数格式设置:
      • 0:货币符号和正数值一起使用圆括号包裹
      • 1:在货币符号和正数值之前加上+
      • 2:在货币符号和正数值之后加上+
      • 3:直接在货币符号之前加上+
      • 4:直接在货币符号之后加上+
    • n_sign_posn:负数格式设置:
      • 0:货币符号和正数值一起使用圆括号包裹
      • 1:在货币符号和正数值之前加上-
      • 2:在货币符号和正数值之后加上-
      • 3:直接在货币符号之前加上-
      • 4:直接在货币符号之后加上-
    • grouping:显示数字组合形式的数组(例如:2 指示 10 00 00 00)
    • mon_grouping:显示货币组合形式的数组(例如:3 指示 1 000 000)

2. 语法

localeconv ( void ) : array

3. 参数说明

该函数不传入任何参数!

4. 示例

<?php

// localeconv()
// 返回一个包含当地数字与货币信息的数组

setlocale(LC_ALL, 'CN');
$arr = localeconv();
var_dump($arr);
/* 输出:
array(18) {
  ["decimal_point"]=>
  string(1) "."
  ["thousands_sep"]=>
  string(1) ","
  ["int_curr_symbol"]=>
  string(3) "XDR"
  ["currency_symbol"]=>
  string(1) ""
  ["mon_decimal_point"]=>
  string(1) "."
  ["mon_thousands_sep"]=>
  string(1) ","
  ["positive_sign"]=>
  string(1) "+"
  ["negative_sign"]=>
  string(1) "-"
  ["int_frac_digits"]=>
  int(2)
  ["frac_digits"]=>
  int(2)
  ["p_cs_precedes"]=>
  int(1)
  ["p_sep_by_space"]=>
  int(0)
  ["n_cs_precedes"]=>
  int(1)
  ["n_sep_by_space"]=>
  int(0)
  ["p_sign_posn"]=>
  int(3)
  ["n_sign_posn"]=>
  int(0)
  ["grouping"]=>
  array(1) {
    [0]=>
    int(3)
  }
  ["mon_grouping"]=>
  array(1) {
    [0]=>
    int(3)
  }
}
*/

5. 延展阅读