php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35835 next() does not work on referenced arrays
Submitted: 2005-12-29 04:39 UTC Modified: 2005-12-29 08:47 UTC
Votes:2
Avg. Score:3.0 ± 2.0
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: ghetalion at ghetalion dot com Assigned:
Status: Closed Package: Arrays related
PHP Version: 4.4.1 OS: Windows XP
Private report: No CVE-ID: None
 [2005-12-29 04:39 UTC] ghetalion at ghetalion dot com
Description:
------------
When using next() on a referenced array, the internal pointer is not moved at all.

Reproduce code:
---------------
function &getEach(&$a)
{
        if(($elem = current($a)) !== FALSE)
        {
                $k = key($a);
                next($a);
                return $a[$k];
        }
        return false;
} 

$alist = array("a", "b", "c");
for(reset($alist); $yup =& getEach($alist);)
{
 echo &yup;
}

Expected result:
----------------
abc

Actual result:
--------------
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(etc)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-29 04:57 UTC] flaming dot cows at gmail dot com
It works as expected (i.e. no bug) on 4.4.0 and 5.0.4 (bundled with Zend IDE on win32 and *nix, as well as on Apache 2.0.54/PHP 5.0.5).
 [2005-12-29 06:39 UTC] judas dot iscariote at gmail dot com
this bug was reported dozens of time.

get :

http://snaps.php.net/win32/php4-win32-STABLE-latest.zip

and try again..
 [2005-12-29 08:47 UTC] sniper@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 27 21:01:33 2024 UTC