You want to round a floating-point number, either to an integer value or to a set number of decimal places.
Use the following functions:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="EN" lang="EN"> <head> <title>Rounding FLoating-Point Numbers</title> <meta Name="Author" Content="Hann So"> </head> <body> <p> <?php echo "Rounding number of 10.3 is: ", round(10.3), "<br />"; echo "Rounding up number of 10.3 is: ", ceil(10.3), "<br />"; echo "Rounding down number of 10.3 is: ", floor(10.3), "<br />"; ?> </p> </body> </html> |