note 36125 deleted from function.round by didou
| From: | didou@php.net | Date: | Fri, 26 Sep 2003 16:24:14 +0000 |
| Subject: | note 36125 deleted from function.round by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-57177@lists.php.net to get a copy of this message | ||
Note Submitter: webmaster***@nospam-****cercaticino.ch
----
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.