#23195 [Csd]: copying an array resets its pointer
| From: | jc at mega-bucks dot co dot jp | Date: | Mon, 23 Jun 2003 00:13:04 +0000 |
| Subject: | #23195 [Csd]: copying an array resets its pointer | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969354787@lists.php.net to get a copy of this message | ||
ID: 23195
User updated by: jc at mega-bucks dot co dot jp
Reported By: jc at mega-bucks dot co dot jp
Status: Closed
Bug Type: Documentation problem
-Operating System: Red Hat Linux 8.0
+Operating System: all
-PHP Version: 4.3.2RC1
+PHP Version: 4.3.0
Assigned To: philip
New Comment:
Thank you!
Can't wait to read the new section on array pointers. I had no idea
that PHP's array were so sensitive to manipulation ;)
Previous Comments:
------------------------------------------------------------------------
[2003-06-21 22:14:19] philip@php.net
This behavior has been documented and will show up when the manual is
next built, thanks for the report :)
http://cvs.php.net/cvs.php/phpdoc/en/reference/array/functions/each.xml
Also, added "explanation of pointers" to the TODO as currently no
section in the manual clearly explains the topic of array pointers.
------------------------------------------------------------------------
[2003-06-10 02:17:11] philip@php.net
pong
------------------------------------------------------------------------
[2003-06-10 02:05:00] jc at mega-bucks dot co dot jp
Fine, it's a lack of documentation about some weird PHP behaviour :)
(yes it *is* weird)
Somebody please fix it. This bug keeps geeting closed and reopened and
passed around. End the torment ^_~
------------------------------------------------------------------------
[2003-06-10 01:58:52] sniper@php.net
This isn't a bug in anything but docs..
------------------------------------------------------------------------
[2003-06-10 00:53:04] philip@php.net
This makes no sense to me, why would assigning an array to another
variable affect the original arrays pointer? Even the array it's
assigned to keeps the original pointer:
<?php
$array = array('a','b','c');
print "1: " . current($array) . "\n"; // a
print "2: " . next($array) . "\n"; // b
$array2 = $array;
print "3: " . current($array) . "\n"; // a
print "4: " . current($array2). "\n"; // b
?>
Either $array should also keep its pointer or $array2 should also have
a reset pointer. I'd assume both would keep the current pointer, or
maybe just $array2 would have a reset pointer :). Current behavior is
certainly not documented, and are you guys sure this isn't a bug?
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/23195
--
Edit this bug report at http://bugs.php.net/?id=23195&edit=1