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
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:
50 - 39 = ?
Subscribe to this entry?

 
 [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 23:01:28 2024 UTC