Number_format() function in php
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 an only allow numeric value and it will be formatted without a decimal point and with 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
1 | number_format(number,decimals,decimalpoint,separator) |
See below Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <?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 ?> |
Please follow and like us: