Bug #10120 Updated: implode(), if empty elements exist
| From: | mfischer@php.net | Date: | Sat, 08 Jun 2002 15:11:39 +0000 |
| Subject: | Bug #10120 Updated: implode(), if empty elements exist | ||
| References: | 1 | Groups: | php.bugs php.doc |
| Request: | Send a blank email to php-bugs+get-9864@lists.php.net to get a copy of this message | ||
ID: 10120
Updated by: mfischer@php.net
Reported By: christian.krause@metis.de
-Status: Open
+Status: Closed
Bug Type: Documentation problem
Operating System: any
PHP Version: 4.0.6
New Comment:
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a
documentation
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2002-06-07 20:44:27] mfischer@php.net
Honestly, I think changing this now in PHP4 is bad. It behaved that way
since 4.0, so changing it with 4.3 is just silly. This asks for more
trouble that we would gain.
Moving over to documentation problem.
------------------------------------------------------------------------
[2001-10-15 16:03:04] jeroen@php.net
The problem: list(<a>,<b>) will assign to <b> first, and only then to
<a>.
This is the case in all versions of PHP 4 (don't know for PHP 3).
Usually this assignment order doesn't matter, but in this case it
does.
(reclassified, analyzed now (was already marked analyzed?))
<?php
list($ar['a'],$ar['b']) = array(1,2);
var_dump($ar);
?>
array(2) {
["b"]=>
int(2)
["a"]=>
int(1)
}
------------------------------------------------------------------------
[2001-10-15 12:52:53] christian.krause@metis.de
The result of implode() is in a wrong order, if a "named index" is
used.
Example exploding and imploding a string (seperated by "+"):
$a = "11+12+13+14";
echo ("a befor execution: ".$a."<BR>");
echo ("this works: ".implode("+", explode("+",
$a))."<BR>");
list(
$r["A"],
$r["B"],
$r["C"],
$r["D"]) = explode("+", $a);
echo ("r between execution:
".$r["A"].$r["B"].$r["C"].$r["D"]."<BR>");
$a = implode("+", $r);
echo ("a after execution: ".$a."<BR>");
Output:
a befor execution: 11+12+13+14
this works: 11+12+13+14
r between execution: 11121314
a after execution: 14+13+12+11
The values in the last row have the wrong order.
------------------------------------------------------------------------
[2001-06-01 16:57:11] sniper@php.net
reproduced with PHP 4.0.6RC1.
------------------------------------------------------------------------
[2001-04-02 15:17:43] christian.krause@metis.de
exploding and imploding a string (seperated by "+"):
$a = "11+12+13+14+++++++++";
echo ("a befor execution: ".$a."<BR>");
list(
$r["A"],
$r["B"],
$r["C"],
$r["D"],
$r["E"],
$r["F"],
$r["G"],
$r["H"],
$r["I"],
$r["J"],
$r["K"],
$r["L"],
$r["M"]) = explode("+", $a);
$a = implode("+", $r);
echo ("a after execution: ".$a."<BR>");
I expect an output (like PHP 3.0.17):
a befor execution: 11+12+13+14+++++++++
a after execution: 11+12+13+14+++++++++
but the output is (in current version):
a befor execution: 11+12+13+14+++++++++
a after execution: +++++++++14+13+12+11
after execution the string is vis versus. It happens only if I try to
implode emty elements. The behaviour is different to PHP 3.0.X
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=10120&edit=1