Re: Currency stored as cents
| From: | Marco Tabini | Date: | Sun, 03 Jul 2005 13:26:18 +0000 |
| Subject: | Re: Currency stored as cents | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-218053@lists.php.net to get a copy of this message | ||
On 7/3/05 1:33 AM, "Tom Rogers" <trogers@kwikin.com> wrote:
> function dollars2cents($value){
> $value = sprintf("%0.2f",trim($value));
> list($a,$b) = explode('.',$value);
> if(floatval($value)<0) $b = $b*-1; //negative amount?
> return intval($a)*100 + intval($b);
> }
Have you tried
round ($value * 100)
?