|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35084 when using reference to array, then current() returns always first element
Submitted: 2005-11-03 11:51 UTC Modified: 2005-11-03 12:15 UTC
From: margus at zone dot ee Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.4.1 OS: SuSE 9.0
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: margus at zone dot ee
New email:
PHP Version: OS:


 [2005-11-03 11:51 UTC] margus at zone dot ee
I have reference to array and iterating through the array using current()/next() loop

The problem is, that $element = current($arr_ref) returns always the first element in array regardless of multiple next($arr_ref) calls before current(...)


It worked in php4.4.0. At the moment the only workaround is to replace everywhere in code:
  $element = current ($arr_ref)
  $element = current(& $arr_ref);

Reproduce code:
$a = array('foot', 'bike');

reset ($a);
echo "A:" . current ($a) . "<BR>";

$b =& $a;

reset ($b);
echo "B:" . current ($b) . "<BR>";

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-03 11:57 UTC] margus at zone dot ee
OS is SuSE 9.0
 [2005-11-03 12:16 UTC] margus at zone dot ee
yes, CVS snapshot (php4-STABLE-200511030951) is working
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Oct 28 12:03:36 2021 UTC