Function: format_number()

function format_number(string $number, int $decimals = 0, string $dec_point = ".", string $thousand_sep = ","): ?string;

Formats the number due to the specified settings.

Details

It is a wrapper over the system function number_format.

Parameters

Name Pass type Value type Default value Description
$number by value string

The number to be formatted.

$decimals by value int 0

The number of digits after the dot.

$dec_point by value string "."

The decimal separator.

$thousand_sep by value string ","

The thousand separator.

Returns

?string

If the number is a vialid number, its formatted value is returned. Otherwise, the empty value is returned. It is usefil if we need to distiguish the empty value and 0.

Authors

Oleg Schildt

Package

Source code