Page 1 of 1

Stripping ',' and '.'

Posted: Fri Jul 13, 2007 10:34 am
by Addos
Hi,
I need to strip out commas and full stops (periods) from a numeric value so that I can pass this to a payment gateway so I was wondering what you can suggest. Is there a specific ‘money’ type PHP script that would do this or is it just some other simple type of ‘strip’ that I can use?

For example I need 6,000.39 to end up like 600039

Thanks for any help
B

Posted: Fri Jul 13, 2007 11:18 am
by RobertGonzalez
str_replace().

Posted: Fri Jul 13, 2007 11:20 am
by Addos
Yep just did this and all lookin good!

Code: Select all

$remove = array(",", ".");
$amount = str_replace($remove, "", "6,8000.00");
echo $amount ;
Thanks