Re: number format?
| From: | Tom Rogers | Date: | Wed, 11 May 2005 03:06:01 +0000 |
| Subject: | Re: number format? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-214892@lists.php.net to get a copy of this message | ||
Hi,
Wednesday, May 11, 2005, 1:34:10 AM, you wrote:
DW> I have a number like -56.98
DW> I need to convert it to -5698. I tried
DW> ---
DW> Outgoing mail is certified Virus Free.
DW> Checked by AVG anti-virus system (http://www.grisoft.com).
DW> Version: 6.0.859 / Virus Database: 585 - Release Date: 2/14/2005
Here is a little function I use to take care of all combination of
inputs:
function dollars2cents($value){
$value = sprintf("%0.2f",trim($value));
list($a,$b) = explode('.',$value);
if(floatval($value)<0) $b = $b*-1;
return intval($a)*100 + intval($b);
}
--
regards,
Tom