round () in php

Wednesday, November 5, 2008 23:41
Posted in category PHP, Programming

The PHP function round () is used to round numbers up or down based on their value (Any decimal .5 or above is rounded up, anything under .5 is rounded down.)

by default it will round to the nearest whole number

< ?php
echo (round(0.70) . "
"); echo (round(0.50) . ""); echo (round(0.20) . ""); echo (round(-3.40) . ""); ?>

out put
1
1
0
-3

Bookmark and Share
You can leave a response, or trackback from your own site.

Leave a Reply