Number Formating in PHP
the number Format function
String number_format(Float number,int decimal ,string dec_point,string thousand_sep);
which is used to format the number to human redable format By grouping to hundreds and thousands
First parameter - the number which is to be formated
Second parameter - the number of decimal points to be displayed in output
Third Parameter - String used to seperate decimal point as default ‘.’
Fouth Parameter - String used to seperate Thousands point as default ‘,’
We can use the function with single,two or all four parameters.
and not with three parameter because if Third is specified then fourth is must.
Eg outputs
<?php
$a= 4567.879
echo number_format($a);
///outputs 4,568
echo number_format($a,2);
///outputs 4,567.88
echo number_format($a,2,’-',’:');
///outputs 4:567-88
?>
