number_format_i18n()
最后更新于:2021-11-27 17:58:34
number_format_i18n( float$number, int$decimals)Convert float number to format based on the locale.
参数
- $number
-
(float) (Required) The number to convert based on locale.
- $decimals
-
(int) (Optional) Precision of the number of decimal places. Default 0.
响应
(string) Converted number in string format.
源文件
文件: gc-includes/functions.php
function number_format_i18n( $number, $decimals = 0 ) {
global $gc_locale;
if ( isset( $gc_locale ) ) {
$formatted = number_format( $number, absint( $decimals ), $gc_locale->number_format['decimal_point'], $gc_locale->number_format['thousands_sep'] );
} else {
$formatted = number_format( $number, absint( $decimals ) );
}
/**
* Filters the number formatted based on the locale.
*
* @since 2.8.0
* @since 4.9.0 The `$number` and `$decimals` parameters were added.
*
* @param string $formatted Converted number in string format.
* @param float $number The number to convert based on locale.
* @param int $decimals Precision of the number of decimal places.
*/
return apply_filters( 'number_format_i18n', $formatted, $number, $decimals );
}