Warning: Trying to access array offset on false in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 216
number_format_i18n() - 将浮点数转换为基于区域设置的格式 - WordPress函数 - WordPress动力
当前浏览:首页 / WordPress函数 / number_format_i18n()

number_format_i18n( float $number, int $decimals )

将浮点数转换为基于区域设置的格式


Warning: Undefined array key -1 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 185

Warning: Undefined array key 3 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 186

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "fbd33194a5ce13c433ddeb80052c4cdc" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "82ccf667d6c457a8b59e0d360c0bab6a" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

format 格式

i18n

  • date_i18n() 根据Unix时间戳和时区偏移量之和(以秒为单位),以本地化格式检索日期
  • number_format_i18n() 将浮点数转换为基于区域设置的格式

参数

$number

(float)(必填) 基于区域设置转换的数字。

$decimals

(int)(可选) 小数位数的精度。默认值为0。


返回

(string) 转换为字符串格式的数字。


更多信息

i18n 是国际化(internationalization)的缩写。



源码

查看源码 官方文档


更新日志

版本描述
2.3.0开始引入

使用示例

  • 示例1

    基本示例

    $number = 3948;
    
    $formatted = number_format_i18n( $number );
    

    $formatted现在将类似于“3,948”。

  • 示例2

    使用$decimal参数

    $number = 3948;
    
    $formatted = number_format_i18n( $number, 2 );
    

    $formatted现在将类似于“3,948.00”。