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

Add a Patch

Pull Requests

Add a Pull Request

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: Fri Feb 23 06:01:28 2024 UTC