php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30914 foreach returns the wrong value
Submitted: 2004-11-26 16:02 UTC Modified: 2004-11-26 16:25 UTC
From: phpbug at billmann-edv dot net Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.3.10RC1 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: phpbug at billmann-edv dot net
New email:
PHP Version: OS:

 

 [2004-11-26 16:02 UTC] phpbug at billmann-edv dot net
Description:
------------
foreach returns the wrong results. Taking a look at the simple example code and the result should make any more explanations unnecessary... ;-)


Reproduce code:
---------------
foreach ( array ( 1 ) as $data ) {
  var_dump ( $data );
}


Expected result:
----------------
int(1)

Actual result:
--------------
array(2) {
  [0]=>
  int(1)
  [1]=>
  int(0)
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-11-26 16:12 UTC] derick@php.net
This works fine here, do you use any accelerator or cache?
 [2004-11-26 16:18 UTC] phpbug at billmann-edv dot net
ok, I just realized that this only happens when you use the ZendOptimizer 2.5.5. Without it and with the new version 2.5.7 it works like expected...
Sorry for the noise ;-)
 [2004-11-26 16:25 UTC] derick@php.net
Not a bug in PHP -> bogus.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 19:01:31 2024 UTC