#36154 [Opn->Bgs]: strange array cursor behavior during array assignment
| From: | sniper@php.net | Date: | Wed, 25 Jan 2006 09:46:37 +0000 |
| Subject: | #36154 [Opn->Bgs]: strange array cursor behavior during array assignment | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-92456@lists.php.net to get a copy of this message | ||
ID: 36154
Updated by: sniper@php.net
Reported By: dmitriy dot buldakov at etadirect dot com
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: FreeBSD 5.3
PHP Version: 4.4.2
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Previous Comments:
------------------------------------------------------------------------
[2006-01-25 10:18:14] dmitriy dot buldakov at etadirect dot com
Description:
------------
In case of assignment to a variable another variable that contains an
array with positioned cursor the old array loses cursor position but
array in new variable cathes it.
I think - the initial array ($a) cursor should be untouched.
The copied array ($c) cursor can be copied or reset, but its behavior
should be documented.
Reproduce code:
---------------
<?php
$a = array(1,2,3,4,5,6,7);
$b = $a;
next($a);
print 'next($a); ...'."\n";
print ' current($a) = '.current($a)."\n";
print ' current($b) = '.current($b)."\n";
$c = $a;
print '$c = $a; ...'."\n";
print ' current($a) = '.current($a)."\n";
print ' current($b) = '.current($b)."\n";
print ' current($c) = '.current($c)."\n";
?>
Expected result:
----------------
bash-3.00# php test.php
next($a); ...
current($a) = 2
current($b) = 1
$c = $a; ...
current($a) = 2
current($b) = 1
current($c) = 1
bash-3.00#
or
bash-3.00# php test.php
next($a); ...
current($a) = 2
current($b) = 1
$c = $a; ...
current($a) = 2
current($b) = 1
current($c) = 2
bash-3.00#
Actual result:
--------------
bash-3.00# php test.php
next($a); ...
current($a) = 2
current($b) = 1
$c = $a; ...
current($a) = 1
current($b) = 1
current($c) = 2
bash-3.00#
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36154&edit=1