Re: number format?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux