how can i make this 20.2525 like this 20.25 when i do a calculation it gives me a 4-digit decimal. Please help me to make it a 2-digit.
Thanks.
2 choices: #1 with printf
x=123.4545; // print a float on (maximum) 9 digit. // wih 2 decimal digit. printf("%9.2f", $x);
#2 with number_format
http://www.php.net/manual/en/function.number-format.php
PM
Hi,
you could also use round():
$number = 20.2525; echo round($number, 2); //Returns 20.25
firemouse2001