php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31153 foreach strange result
Submitted: 2004-12-17 15:24 UTC Modified: 2004-12-17 15:29 UTC
From: andrea dot busia at axis-sv dot it Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.3.10 OS: Linux
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: andrea dot busia at axis-sv dot it
New email:
PHP Version: OS:

 

 [2004-12-17 15:24 UTC] andrea dot busia at axis-sv dot it
Description:
------------
When I use foreach on an array the values are wrong. It's very critical.


Reproduce code:
---------------
<?
$a=array(5,10,15);
foreach($a as $b) var_dump($b);
?>

Expected result:
----------------
int(5)
int(10)
int(15)

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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-17 15:29 UTC] edink@php.net
Do not file bugs when you have Zend extensions (zend_extension=)
loaded. Examples are Zend Optimizer, Zend Debugger, Turck MM Cache,
APC, Xdebug and ionCube loader.  These extensions often modify engine
behavior which is not related to PHP itself.

Update ZendOptimizer and the problem will go away.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 22:01:27 2024 UTC