note 72706 deleted from function.round by danbrown

From: Date: Sun, 17 May 2009 16:19:01 +0000
Subject: note 72706 deleted from function.round by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-154795@lists.php.net to get a copy of this message
Note Submitter: pokusman at gmail dot com ---- <php? function RoundPrice($Price) { $diff = $Price - floor($Price); if ($diff<=0.25) { $Price = floor($Price) + 0.25; }; if ($diff>0.25 && $diff<=0.5) { $Price = floor($Price) + 0.5; }; if ($diff>0.5 && $diff<=0.75) { $Price = floor($Price) + 0.75; }; if ($diff>0.75) { $Price = floor($Price) + 1; }; return $Price; } $Price = "369.68"; $NewPrice = RoundPrice($Price); //369.75 echo "Old price: £".$Price." new price £".$NewPrice; ?> Peter Tyson

« previous php.notes (#154795) next »