#35270 [Fbk]: copying an array no longer resets the index
| From: | tony2001@php.net | Date: | Fri, 18 Nov 2005 08:40:12 +0000 |
| Subject: | #35270 [Fbk]: copying an array no longer resets the index | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-88457@lists.php.net to get a copy of this message | ||
ID: 35270
Updated by: tony2001@php.net
Reported By: andrej at blueshoes dot org
Status: Feedback
-Bug Type: Documentation problem
+Bug Type: Arrays related
Operating System: windows
-PHP Version: Irrelevant
+PHP Version: ?
New Comment:
There is no such version as "Irrelevant".
Or did you really try it with *ALL* versions since 1.0.0 ?
Previous Comments:
------------------------------------------------------------------------
[2005-11-18 09:05:45] derick@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php4-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
------------------------------------------------------------------------
[2005-11-18 05:15:02] andrej at blueshoes dot org
Description:
------------
the documentation for each
http://www.php.net/manual/en/function.each.php
has a caution which was
true for php up to 4.3.11, but it's not for 4.4.1 anymore.
Reproduce code:
---------------
$array = array('a', 'b', 'c', 'd', 'e',
'f', 'g');
$breakAt = 3;
$i=0;
while (list($key, $val) = each($array)) {
if ($i > $breakAt) break;
$i++;
}
$brray = $array;
$aCurrent = current($array);
$bCurrent = current($brray);
$actual = $aCurrent;
$expected = 'a';
$this->assertEquals($expected, $actual, "failed? could be a good
thing. check the code.");
$actual = $bCurrent;
$expected = 'f';
$this->assertEquals($expected, $actual, "failed? could be a good
thing.");
Expected result:
----------------
a or f
Actual result:
--------------
a or f
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35270&edit=1