round(): Rounding off variable values in PHP

echo "The number = ". $number // will display 25.66745 
echo "<br>Rounded value of the number = ".round($number,2); // will display25.67 
echo "<br>Rounded value of the number = ".round($number); // will display 26 
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.
Some time we may use php number formatting function to display a proper formatted number.

We can round off the number to lower value is by using floor function and we can also round off to next higher number by using ceil function in PHP

Here is a comparison between ceil(), floor() and round() function. For different input numbers we will get different values by using these functions.

PHP video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2024 All rights reserved worldwide Privacy Policy Disclaimer