php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35095 Array internal pointer / function by reference
Submitted: 2005-11-04 01:57 UTC Modified: 2005-11-04 09:03 UTC
From: yanik at lecourriel dot com Assigned:
Status: Not a bug Package: Variables related
PHP Version: 4.4.1 OS: Windows XP SP2
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: yanik at lecourriel dot com
New email:
PHP Version: OS:

 

 [2005-11-04 01:57 UTC] yanik at lecourriel dot com
Description:
------------
Array internal pointer does't work propely when passed to a function by reference.

Reproduce code:
---------------
$t = array('firstName' => 'Yanik', 'lastName' => 'Lupien');

// Cause an infinit loop, always display first key
function test(&$t) {
 for(reset($t); !is_null($key = key($t)); next($t)) {
  print "{$key}<br/>";	
 }
}

//Work well
for(reset($t); !is_null($key = key($t)); next($t)) {
	print "{$key}<br/>";	
}

// Infinit loop
test($t);

Expected result:
----------------
firstName
lastName
firstName
lastName


Actual result:
--------------
firstName
lastName
firstName
firstName
firstName
firstName
firstName
firstName
...


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-04 09:03 UTC] derick@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 02:01:28 2024 UTC