Rounding of Numbers in Php
To round of numbers in Php you can use simply use round() functions
Syntax 1:
$v2=round($v1,no of decimals after point)
$v1—>Value to be rounded off
$v2—>Value rounded off
Example:
$v1=6.78990
$v2=round($v1,2)
$v2 would be “6.78″
Syntax 2:
To make numbers as whole numbers also you can use round() function
$v2=round($v1);
Example:
$v1=7.556456546;
$v2=round($v1);
Result:
$v2 would be “7″
This entry was posted on Thursday, May 14th, 2009 at 5:52 pm and is filed under Php. You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.