Format a number in a smarter way, i.e., decimal places are omitted when necessary. Given the 2 decimal places, the value 5.00 will be shown 5 whereas the value 5.01 will be shown as it is.
Parameters | |||
---|---|---|---|
int
|
$value |
A number to be formatted |
# |
int
|
$decimals = 2 |
The decimal places. Default is 2. |
# |
string
|
$unit = '' |
The unit appended to the number (optional) |
# |
Returns | |
---|---|
string
|
The formatted number |