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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 08:01:29 2024 UTC