C.F. Scheidecker Antunes wrote:

I have a few users that use a different number format, other than the US one, which is 1.526,23 . That is, the comma is used as a separator for the fractional part of the number (.23) and the dot is used to separate
thousands. Therefore, I need to convert 1.526,23 to 1,526.23, invert the comma and the dot. Some numbers are formated correctly so nothing needs to be done, while other need that.


I have writen a function to perform that but it reads char by char and has test cases. I first check the position of the dot and the comma. It one is higher than the other than I need to convert, if not than I do
nothing. I would like to make it simpler and more efficent and for that I need some help from some of the PHP regex experts.

Store the raw number, 1234.56 and then use number_format() to add the appropriate commas and periods. You can tailor the number_format() call to the user so they get the numbers in the format they like.


--

---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to