Page 1 of 1

How do I convert £40,995 to 40995

Posted: Mon Jul 23, 2007 10:49 am
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

Posted: Mon Jul 23, 2007 11:09 am
by stereofrog
try

Code: Select all

preg_replace('/\D+/', '', $value);

Works perfectly

Posted: Mon Jul 23, 2007 1:32 pm
by chopschops
Excellent - thanks for the quick response!