0

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:

  • 1
  • 1,0
  • 1,00
  • ,5
  • etc...

Not allowed:

  • 1.0
  • 1,000
  • -,5
  • abc
  • 0,0€
  • etc...

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?

Abhranil Das
  • 5,702
  • 6
  • 35
  • 42
Gareth Maclean
  • 109
  • 1
  • 2
  • 9
  • 1
    possible duplicate [PHP Unformat money](http://stackoverflow.com/questions/5139793/php-unformat-money/5140046#5140046) – Gordon Mar 07 '11 at 22:27
  • Tag `german` removed as part of the [**2012 cleanup**](http://meta.stackexchange.com/questions/128315/the-great-stack-overflow-tag-question-cleanup-of-2012). – Abhranil Das Apr 30 '12 at 12:18

1 Answers1

1

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

criticus
  • 1,571
  • 8
  • 15
  • I'm using the Fabric component for Joomla and it doesn't support it. I can save 0,5 as 0.5 but not as 0.50 and if a user edits the value it is then displayed as 0.5 so I have to save the value as text. – Gareth Maclean Mar 07 '11 at 20:24