note 72706 added to function.round

From: Date: Tue, 30 Jan 2007 15:06:46 +0000
Subject: note 72706 added to function.round
Groups: php.notes 
Request: Send a blank email to php-notes+get-122355@lists.php.net to get a copy of this message
<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 ---- Server IP: 83.138.144.80 Probable Submitter: 86.135.106.61 ---- Manual Page -- http://www.php.net/manual/en/function.round.php Edit -- https://master.php.net/note/edit/72706 Del: integrated -- https://master.php.net/note/delete/72706/integrated Del: useless -- https://master.php.net/note/delete/72706/useless Del: bad code -- https://master.php.net/note/delete/72706/bad+code Del: spam -- https://master.php.net/note/delete/72706/spam Del: non-english -- https://master.php.net/note/delete/72706/non-english Del: in docs -- https://master.php.net/note/delete/72706/in+docs Del: other reasons-- https://master.php.net/note/delete/72706 Reject -- https://master.php.net/note/reject/72706 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#122355) next »