[PHP] Correct number format (curency)

2003-02-20 Thread Robert Mena
Hi,

I have one application where the users enter a curency
value.

Unfortunately even tough I write the correct format
I keep receiving all kinds.

Example

1.000,00
1000.00
1,000.00

I would like to convert those to a single format
1000.00

Is there any function in php that already does that ? 
Or perhaps any code snippets ?

thanks.

__
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/

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




Re: [PHP] Correct number format (curency)

2003-02-20 Thread Bas Jobsen
 Example

 1.000,00
 1000.00
 1,000.00

 I would like to convert those to a single format
 1000.00
?
function money($money)
{
/* written by [EMAIL PROTECTED] */
$money=str_replace(array(',','.'),'',$money);
$money=substr($money,0,strlen($money)-2).'.'.substr($money,-2);
}
$money='1.000,00';
money($money);
echo $money.\n;
$money='1000.00';
money($money);
echo $money.\n;
$money='1,000.00';
money($money);
echo $money.\n;
?

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




RE: [PHP] Correct number format (curency)

2003-02-20 Thread Dennis Cole
This should also work, without any problems.

- Php Code --
?
$total = 1.000,00;
$total = str_replace(',','',$total);

echo number_format($total, 2, '.', '');
?
- End PHP Code --

- Original Message -
From: Bas Jobsen [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 20, 2003 10:05 AM
To: Robert Mena; php mailing list
Subject: Re: [PHP] Correct number format (curency)


 Example

 1.000,00
 1000.00
 1,000.00

 I would like to convert those to a single format
 1000.00
?
function money($money)
{
/* written by [EMAIL PROTECTED] */
$money=str_replace(array(',','.'),'',$money);
$money=substr($money,0,strlen($money)-2).'.'.substr($money,-2);
}
$money='1.000,00';
money($money);
echo $money.\n;
$money='1000.00';
money($money);
echo $money.\n;
$money='1,000.00';
money($money);
echo $money.\n;
?

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


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