note 47365 deleted from function.round by googleguy

From: Date: Sun, 09 Dec 2012 08:25:59 +0000
Subject: note 47365 deleted from function.round by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-192424@lists.php.net to get a copy of this message
Note Submitter: martin at chinese-monkey dot com ---- If you didn't want to use 'ceil()' or 'floor()' as it only rounds to a whole number u could do this: <?php $actual_value = 3.352; $number = 0.01; //how many decimal places you want it to be $temp1 = $actual_value * 2; $temp2 = $temp1 + $number; //'+ $number' if rounding up '- $number' if rounding down $temp3 = $temp2 / 2; $new_value = round($temp3, 2); echo $new_value; // 3.36 ?>

« previous php.notes (#192424) next »