RE: [PHP] rounding a number

From: Date: Mon, 24 Jun 2002 04:01:00 +0000
Subject: RE: [PHP] rounding a number
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-103529@lists.php.net to get a copy of this message
I think what you're looking for is number_format() - you can set decimal places with it and used in combo with round(), ceil(), and/or floor(), you should be able to achieved the desired result. http://www.php.net/manual/en/function.number-format.php HTH, Jason Soza -----Original Message----- From: Phil Schwarzmann [mailto:pschwar@jhmi.edu] Sent: Sunday, June 23, 2002 7:35 PM To: php-general@lists.php.net Subject: [PHP] rounding a number I want to round a number to the nearest decimal place... if the number is 4.623, I want it to display 4.6 if the number is 2.36, I want it to display 2.7 Is there a function that does this? round(), ceil(), floor() don't do this and I've checked through all the math functions in my handy-dandy "PHP Functions" reference book. Thanks for your help!!! Or......if it's too hard to do that, I could just use a function that chops off the end of some decimals, like... if the number is 2.343234, I want just 2.3 or if the number is 2.545434534534534534, I want just 2.5 Thanks!!!!!!

« previous php.general (#103529) next »