[RESOLVED] Price PCRE
I need a solid regx for the below inputs/outputs.
£165,454.34 = 165454.34
£23,934 = 23934
£blah = 0
£23 pounds = 23
£23.39.39 = 23.39
Last edited by MrCoder; 01-09-2007 at 07:21 AM.
NOTE: this won't care if the input starts with a "£", "$", or no currency symbol.
$testData = array(
foreach($testData as $input)
$output = round(preg_replace('/[^\d.]/', '', $input), 2);
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
How to Ask Questions the Smart Way
(not affiliated with this site, but well worth reading)
Cheers mate, I didnt even think about using round() or number_format().
I should sit back and think more offen lol!
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)