Stripping ',' and '.'

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Addos
Forum Contributor
Posts: 305
Joined: Mon Jan 17, 2005 4:13 pm

Stripping ',' and '.'

Post 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
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

str_replace().
Addos
Forum Contributor
Posts: 305
Joined: Mon Jan 17, 2005 4:13 pm

Post 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
Post Reply