php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35070 next() does not work with global variable
Submitted: 2005-11-02 19:03 UTC Modified: 2005-11-02 20:47 UTC
From: tokul at users dot sourceforge dot net Assigned:
Status: Closed Package: Arrays related
PHP Version: 4.4.1 OS: Linux Debian Sarge
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: tokul at users dot sourceforge dot net
New email:
PHP Version: OS:

 

 [2005-11-02 19:03 UTC] tokul at users dot sourceforge dot net
Description:
------------
next() does not advance the internal array pointer, if it is run on global variable inside function.

Reproduce code:
---------------
global $test;
$test=array(1=>'one',2=>'two',3=>'three');
function test() {
  global $test;
  echo current($test)."\n";
  next($test);
  echo current($test)."\n";
  next($test);
  echo current($test)."\n";
}
test();

Expected result:
----------------
one
two
three

Actual result:
--------------
one
one
one

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-02 20:43 UTC] tokul at users dot sourceforge dot net
I know about 35067 bug, but it is still reproducable in php4-STABLE-200511021752
 [2005-11-02 20:47 UTC] derick@php.net
Please the next snapshot, sometimes there is a short delay.
 [2005-11-02 20:47 UTC] iliaa@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-2025 The PHP Group
All rights reserved.
Last updated: Fri Mar 14 15:01:30 2025 UTC