note 100322 modified in function.round by danbrown

From: Date: Thu, 07 Oct 2010 23:11:55 +0000
Subject: note 100322 modified in function.round by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-173072@lists.php.net to get a copy of this message
Here is function that rounds to a specified increment, but always up. I had to use it for price adjustment that always went up to $5 increments. <?php function roundUpTo($number, $increments) { $increments = 1 / $increments; return (ceil($number * $increments) / $increments); } ?> --was-- Here is function similar to Daniel's that rounds to a specified increment, but always up. I had to use it for price adjustment that always went up to $5 increments. <?php function roundUpTo($number, $increments) { $increments = 1 / $increments; return (ceil($number * $increments) / $increments); } ?> http://php.net/manual/en/function.round.php

« previous php.notes (#173072) next »