PHP round() Function Example

PHP round() Function Example


Posted in : PHP Posted on : January 28, 2011 at 5:41 PM Comments : [ 0 ]

The round() function round the number up or down based on their value.

PHP round() Function Example:

The round() function round the number up or down based on their value. The number have two part first is decimal and after decimal point is fraction, if the value of fraction part is greater then .5 then round() function round up these number or if the value of fraction part less then .5 then round function round down these number.

Example:

<?php
echo(round(0.80) . "<br />");
echo(round(0.51) . "<br />");
echo(round(0.45) . "<br />");
echo(round(-6.50) . "<br />");
echo(round(-6.49));
?>

Output:

The output of this example is:

1
1
0
-7
-6

Download Example Code

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics