|
|
|
Rounding off varable values in PHP |
We can round off variable values to a whole number or to some value with precision. You can read the article on number formatting to know how to format numbers using PHP. For simple rounding here is the code to do all that. WE will store the value in a variable and then display by rounding off it by using round function.
See the code below
$number=25.66745; echo "The number = ".
$number;
// will display 25.66745 echo "<br>Rounded
value of the number = ".round($number,2); // will display
25.67 echo "<br>Rounded
value of the number = ".round($number); // will display
26
Some time we may use php number formatting function to display a proper formatted number.
Visit the links below to see other php math functions.
| |
| Subscribe |
|
Submit your email address and receive
article and product notifications. Your email is safe with us.
|
|
|
|
|
|