I have a web app that is used in a number of countries, including ones such as Brazil, where the comma is used as a decimal separator. This is causing problems with my SQL queries, as it is trying to update a number field with "0,013" when it should be "0.013". The result is simply "0".
I set the internationalization environment variables with:
setlocale( LC_ALL, "ptg"); putenv("LC_ALL=pt_BR); putenv("TZ=America/Sao_Paulo);
When it comes to the dots and commas, I use a simple number_format() to display it to the user as they would expect. But unfortunately, once the local is set, any calculations done by PHP result in a comma-separated value.
$numval = 0.0155 - 0.0133; echo $numval;
Is it possible to still set the locale as above, but force PHP to use the period decimal separator?
Formatting each value before writing to the database is the last option I'd like to consider.
Thanks in advance for any help.