php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29593 join() doesn't respect locale settings
Submitted: 2004-08-09 22:46 UTC Modified: 2004-08-17 16:09 UTC
From: rafael dot lima at email dot com dot br Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.3.8 OS: Linux Gentoo
Private report: No CVE-ID: None
 [2004-08-09 22:46 UTC] rafael dot lima at email dot com dot br
Description:
------------
When a use the join() function on an array that have a float value, the string returned contains the values formatted without the setlocale() settings

Reproduce code:
---------------
setlocale(LC_ALL,'pt_BR');

$x="10,01";
$a[1] = $x;
$a[2] = floatval(str_replace(",",".",$x));
$a[3] = floatval('10.01');

echo '<pre>';
print_r($a);
echo '</pre>';
$b = join("<br>",$a);
echo ($b);


Expected result:
----------------
Array
(
    [1] => 10,01
    [2] => 10,01
    [3] => 10,01
)

10,01
10,01
10,01

Actual result:
--------------
Array
(
    [1] => 10,01
    [2] => 10,01
    [3] => 10,01
)

10,01
10.01
10.01

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-17 15:41 UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

Use var_dump($_POST); and you'll see that variables are on their places. Debug you code.
 [2004-08-17 15:41 UTC] tony2001@php.net
Oops. Wrong report.
 [2004-08-17 16:09 UTC] tony2001@php.net
No, there is no bug. 
To check it out, just change print_r() to var_dump() and you'll see that there is still 1 string and 2 floats in the array.
print_r() uses your locale settings, while var_dump() prints variable contents in it's original state, so 2-nd & 3-rd elements are changed in the print_r() output. 
You can comment out line with setlocale() and it will work too.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sun Jul 12 05:00:02 2026 UTC