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
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: 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: Sat Dec 21 15:01:29 2024 UTC