функция
since 2.3.0
number_format_i18n()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
number_format_i18n( float $number, int $decimals ): string
Описание
Преобразует число с плавающей точкой в формат, зависящий от локали.
Параметры
$number
float
обязательный
Число для преобразования в соответствии с локалью.
$decimals
int
необязательный
Точность — количество знаков после запятой. Значение по умолчанию 0.
Возвращаемое значение
string
Исходный код
wp-includes/functions.php:424
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` 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 );
}
История изменений
| Версия | Описание |
|---|---|
| 2.3.0 | Introduced. |

