In this article, we will explain to you how to use the php number_format function. we will give you simple example for php number_format() function example.
The number_format() function return the readable number. it takes one, two, or four parameters and doesn’t take three parameters. This function gives you an easy way to format numbers for displaying to the user.
The number parameter is the only allowed numeric value and it will be formatted without a decimal point and with a comma (,) as the thousands separator.
The decimals parameter is an optional value. how many numbers after show decimal point.
The decimal point parameter is an optional value. it is specified which symbols use.
The separator parameter is an optional value. it is specified the thousands separator.
Syntax
number_format(number,decimals,decimalpoint,separator)
See below Example
<?php $number=100000; echo number_format($number).'<br>'; echo number_format($number, 2).'<br>'; echo number_format($number, 3).'<br>'; echo number_format($number, 2, ',', '.'); //output //100,000 //100,000.00 //100,000.000 //100.000,00 ?>