Page 1 of 1

HELP -> Change 2,500,000.40 to 2500000.00

Posted: Fri Dec 16, 2005 10:08 am
by pido
How do i change this variable to 2 decimals??? 2,500,010.40 -> 2500010.40
Any idea how I do this??? Thnx... :D

Re: HELP -> Change 2,500,000.40 to 2500000.00

Posted: Fri Dec 16, 2005 10:10 am
by hawleyjr
pido wrote:How do i change this variable to 2 decimals??? 2,500,010.40 -> 2500010.40
Any idea how I do this??? Thnx... :D

The number is already two decimals. Do you mean remove the commas?

Posted: Fri Dec 16, 2005 10:16 am
by Burrito
check out number_format()

Posted: Fri Dec 16, 2005 10:20 am
by foobar
It seems like he just wants to get rid of the commata.

Code: Select all

$teh_numbar = '2,500,010.40';

$teh_numbar = round(floatval((str_replace(',', '', $teh_numbar))), 2);

Posted: Fri Dec 16, 2005 10:20 am
by pido
YEA!! you rite!!! my bad :oops: how do i do that hawleyjr??

Posted: Fri Dec 16, 2005 10:26 am
by hawleyjr

Code: Select all

$myNumber = '2,500,010.40';
$result = str_replace(',', '', $myNumber);