php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35491 Nice missbehaviour using arrays in functions.
Submitted: 2005-11-30 15:02 UTC Modified: 2005-11-30 16:17 UTC
From: stephan dot skusa at lippe-net dot de Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.4.1 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
47 - 41 = ?
Subscribe to this entry?

 
 [2005-11-30 15:02 UTC] stephan dot skusa at lippe-net dot de
Description:
------------
The call of test() results into an endless loop. The first for() works well, the for() in the function is the problem.
And the Problem appears even if the first for() is left out.

Reproduce code:
---------------
<?PHP
    

$arr = array ('a' => 1, 'c' => 2);    

for (reset ($arr); $key = key ($arr); next ($arr)) {   
   echo $key;   
}   

echo "PING";

function test() {
   global $arr;
   for (reset ($arr); $key = key ($arr); next ($arr)) {
      echo $key;
   }
}   
    
test();
  
?>

Expected result:
----------------
Output of "acPINGac"

Actual result:
--------------
Endless Loop

Output of "acPINGaaaaaaaaaaaaa ... to be continued" 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-30 15:14 UTC] tony2001@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.

Reported a gazillion of times before.
Fixed long time ago.
 [2005-11-30 15:37 UTC] stephan dot skusa at lippe-net dot de
I didn't found an equal bug description.

Not everybody describes a bug the same way, maybe that's the reason!
 [2005-11-30 16:17 UTC] stephan dot skusa at lippe-net dot de
Not really ... but it doesn't really matter to me what you think.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 03 07:01:29 2024 UTC