note 36125 added to function.round

From: Date: Fri, 26 Sep 2003 16:17:06 +0000
Subject: note 36125 added to function.round
Groups: php.notes 
Request: Send a blank email to php-notes+get-57176@lists.php.net to get a copy of this message
There is a little script that can be used to round down a currency to 5 (five) cents situable for Swiss Francs (CHF): function formatsfr($number) { $tab = explode('.',$number); $roundcent = round($tab[1]/5)*5; $rcprint = sprintf ("%02d", $roundcent); if($tab[1]>=98) { $fnumber = $tab[0] + "1"; $cent = "00"; } else { $fnumber = $tab[0]; $cent = $rcprint; } $number = $fnumber.".".$cent; return $number; } If you input a currency of 1.23 it return a value of 1.25 or if you input a currency of 1.98 it return a value of 2.00, etc. ---- Manual Page -- http://www.php.net/manual/en/function.round.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+36125 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+36125&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+36125&report=yes

« previous php.notes (#57176) next »