php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31012 error with foreach
Submitted: 2004-12-07 17:46 UTC Modified: 2004-12-07 22:28 UTC
From: DeyV at php dot pl Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 4.3.10RC1 OS: win xp
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: DeyV at php dot pl
New email:
PHP Version: OS:

 

 [2004-12-07 17:46 UTC] DeyV at php dot pl
Description:
------------
In this version in foreach without $key parametr, the $value always is returned as array, when 
0 => value
1 => key 

Reproduce code:
---------------
$a = array (
    1 => 'test1', 
    2 => 'test2', 
    "three" => 1,
    "four"  => 2,
    "five"  => 3
);

foreach( $a as $v ) {
    print $v."\n";
}
var_dump( $v );


Expected result:
----------------
test test2 1 2 3 
int(3)

Actual result:
--------------
Array Array Array Array Array 
array(2) { [0]=>  int(3) [1]=>  string(4) "five" }

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-07 17:55 UTC] tony2001@php.net
Please, make sure that you disabled all Zend extensions (Zend Optimizer etc.) and try again.
 [2004-12-07 22:13 UTC] DeyV at php dot pl
Interesting. 
Without Zend Optimizer-2.5.5 this work correctly. 

Sorry.
 [2004-12-07 22:28 UTC] tony2001@php.net
Not a PHP bug -> bogus.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jun 09 21:01:27 2025 UTC