Bug #10120 Updated: implode(), if named index exists
| From: | christian dot krause at metis dot de | Date: | Mon, 15 Oct 2001 16:52:53 +0000 |
| Subject: | Bug #10120 Updated: implode(), if named index exists | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-67964@lists.php.net to get a copy of this message | ||
ID: 10120
User updated by: christian.krause@metis.de
Reported By: christian.krause@metis.de
Old Summary: implode(), if empty elements exist
Status: Analyzed
Bug Type: Arrays related
Operating System: Win 98se
Old PHP Version: 4.0.4pl1
PHP Version: 4.0.6
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[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