根据区域设置将浮点数转换为格式。

原型

number_format_i18n( float $number, int $decimals )

参数

$number (float) (Required) 要根据区域设置进行转换的数字。

$decimals (int) (Optional)  精度小数位数。默认值为0。

返回值

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

源文件

路径:wp-includes/functions.php

<?php
...
function number_format_i18n( $number, $decimals = 0 ) {
	global $wp_locale;
	if ( isset( $wp_locale ) ) {
		$formatted = number_format( $number, absint( $decimals ), $wp_locale->number_format['decimal_point'], $wp_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` arguments 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 );
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/number_format_i18n/