Koralek M.
Koralek M.

Reputation: 3341

Decimal comma instead of decimal point

How can I change a decimal point to decimal comma by setting it in php.ini without any changes in code on my local server running on Windows?

3.14 >> 3,14

I tried to set

intl.default_locale = cs_CZ 

without any results.

EDIT: The reason why I'm asking is that if I execute the code on hosting I get numbers with decimal comma, but when I transfer same code to my local server there is a decimal point. Where is the catch?

For example - Linux hosting:

echo 100 / 3; // 33,333333333333

Local server on Windows:

echo 100 / 3; // 33.333333333333

What is the reason?

EDIT 2: If I use

setlocale(LC_NUMERIC, 'cs_CZ');
echo 100 / 3;

I will get the same result 33.333333333333, so the catch must be in configuration files or in Windows itself.

Upvotes: 2

Views: 6365

Answers (3)

javier_domenech
javier_domenech

Reputation: 6263

For linux:

This is a local configuration issue, probably caused after installing php-intl recently, which changed it for you unintentionally.

Edit your /etc/default/locale file and change the LC_NUMERIC line to

LC_NUMERIC = "en_GB.UTF-8"

You might want to change any other setting there, then reboot.

Upvotes: 0

CodeManX
CodeManX

Reputation: 11885

intl.default_locale sets the locale for intl functions only, see this comment.

If your code doesn't use an intl function for the number formatting, there's no way around changing the code. It should be as easy as setting the locale for money / number formatting to Czech.

For money:

setlocale(LC_MONETARY, 'cs_CZ');

For numbers:

setlocale(LC_NUMERIC, 'cs_CZ');

Upvotes: 4

Koralek M.
Koralek M.

Reputation: 3341

So what I discovered is that only way, how you can do this on Windows is:

setlocale(LC_ALL, 'czech');

Thanks to http://msdn.microsoft.com/en-us/library/39cwe7zf%28v=vs.90%29.aspx

Upvotes: 1

Related Questions