How do I convert £40,995 to 40995

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
chopschops
Forum Newbie
Posts: 2
Joined: Mon Jul 23, 2007 10:42 am

How do I convert £40,995 to 40995

Post by chopschops »

Hi

Newbie here - but loving learning php. Most questions I've managed to answer from forums but this one I'm stuck on - sorry if its so easy to be annoying.

How do I convert a string that is in currency format e.g. £40,995 to 40995 i.e. a numeric ,so I can do arithmatic on it?

Thanks
User avatar
stereofrog
Forum Contributor
Posts: 386
Joined: Mon Dec 04, 2006 6:10 am

Post by stereofrog »

try

Code: Select all

preg_replace('/\D+/', '', $value);
chopschops
Forum Newbie
Posts: 2
Joined: Mon Jul 23, 2007 10:42 am

Works perfectly

Post by chopschops »

Excellent - thanks for the quick response!
Post Reply