Gareth Maclean
Gareth Maclean

Reputation: 109

PHP German Currency Regular Expression

I've been trying all sorts of strange combinations but just can't get my head around Regular Expressions, could somebody help me please. In Germany the , is used instead of a . and a . is used instead of a , e.g. Germen= 10.000,00 English= 10,000.00 I don't need a thousand seperator.

Allowed:

Not allowed:

Is it possible to change the format with a Regular Expression so if someone were to enter: 2 or 2,0 it would be changed to 2,00 and if someone where to enter ,5 it would be changed to 0,50?

Upvotes: 0

Views: 678

Answers (1)

criticus
criticus

Reputation: 1599

Work with floats in php depends on your locale. You might want to see Manual

Upvotes: 1

Related Questions