PHP: number_format() with example

The PHP function number_format() is the function is used to format the given number in a specific format. The below example will show how to format the given number with decimal points. The number_format() will accept 3 parameters as defined below,

Syntax:​

NUMBER_VALUE : Number as need to format(Ex:1234567)
NUMBERS_DECIMAL_POINT: Total number of digits show after decimal points
SYMBOL: Decimal point dentor(Ex: .). 
 
$number = number_format(NUMBER_VALUE, NUMBERS_DECIMAL_POINT, SYMBOL);

Example:

$number = number_format(123456, 2, '.');
print $number;
Output:
1234.56

 

Category: