php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35270 copying an array no longer resets the index
Submitted: 2005-11-18 05:15 UTC Modified: 2005-11-26 01:00 UTC
From: andrej at blueshoes dot org Assigned:
Status: No Feedback Package: Arrays related
PHP Version: ? OS: windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: andrej at blueshoes dot org
New email:
PHP Version: OS:

 

 [2005-11-18 05:15 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-18 09:40 UTC] tony2001@php.net
There is no such version as "Irrelevant".
Or did you really try it with *ALL* versions since 1.0.0 ?
 [2005-11-18 10:07 UTC] vrana@php.net
This was originally a Documentation problem so Irrelevant was filled by our bug system. I guess it's 4.4.1.
 [2005-11-26 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 14:01:30 2024 UTC