|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68203 implode() for foat numbers use setlocale() settings!
Submitted: 2014-10-09 22:54 UTC Modified: 2014-12-06 20:10 UTC
From: i dot am dot brutto at gmail dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.5.17 OS: Ubuntu
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: i dot am dot brutto at gmail dot com
New email:
PHP Version: OS:


 [2014-10-09 22:54 UTC] i dot am dot brutto at gmail dot com
From manual page:
There is no any information aboout this strange behavior. =\
Detect this was difficult enough because do not expect problems in such simple core things.

It's the same bug (, but it dodn't fixed (as there marked).

Test script:

$locale = 'ru_RU';
putenv("LANG=$locale" . '.UTF-8');
putenv("LANGUAGE=$locale" . '.UTF-8');
setlocale(LC_ALL, $locale . '.UTF-8'); // . '.UTF-8'

$arr = array(12.12,12,23,21.44,67.88);
print_r(implode(',', $arr));

Expected result:
there is no logic. other string functions not affected with this. and nowhere information about it.

$arr = array(12.12,12,23,21.44,67.88);
print_r(implode(' | ', $arr)); 

expected => 12.12 | 12 | 23 | 21.44 | 67.88
current => 12,12 | 12 | 23 | 21,44 | 67,88 (setlocale to ru_RU for example)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-10-10 03:51 UTC] chris at ctankersley dot com
Created a test for this:

implode() function - Floats use locale settings
$locale = 'ru_RU';
putenv("LANG=$locale" . '.UTF-8');
putenv("LANGUAGE=$locale" . '.UTF-8');
setlocale(LC_ALL, $locale . '.UTF-8'); // . '.UTF-8'

$arr = array(12.12,12,23,21.44,67.88);
print_r(implode(',', $arr));

From my end though, I couldn't seem to reproduce this. I tested this on a Windows build of 7.0.0-dev and on Ubuntu using their 5.5.9 package. also shows that this works properly:
 [2014-10-10 08:05 UTC] i dot am dot brutto at gmail dot com
reproduced on my Ubuntu 12.04(LTS) with PHP (cli) (built: Jul 24 2014 15:44:50) and PHP (cli) (built: Sep 25 2014 09:07:54)

Btw, check your installed locales via `locale -a`. RU locale must be installed.
 [2014-10-10 11:59 UTC] i dot am dot brutto at gmail dot com
Finally i realise what happens: all function return stings auto-format floats according to setllocale(). It means that event simple `echo $floatVar;` will be formatted as well. 

Ok. These logic clear. It would be good to add info about it in manual... But! If decimal sign are auto-formatted, expected that thousand sign will be also formatted (as in number_format()). Unfortunately that is not right in this php-version. Probably it was described somewhere else. IDN

>>>> test:
$locale = 'ru_RU';
putenv("LANG=$locale" . '.UTF-8');
putenv("LANGUAGE=$locale" . '.UTF-8');
setlocale(LC_ALL, $locale . '.UTF-8');

$number = 12300.45;

print_r(is_float($number)); // => true
print_r($number); // => 12300,45 ][ Expected: 12 300,45
print_r('This is :' . $number); // => 'This is 12300,45' ][ Expected: 12 300,45
print_r(implode('::', array($number, 12.89))); //=> '12300,45::12,89' ][ Expected 12 300,45::12,89
 [2014-12-06 20:10 UTC]
-Status: Open +Status: Not a bug
 [2014-12-06 20:10 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 21 21:01:33 2024 UTC