#31126 [NEW]: Serious Bug in foreach
| From: | rf at inmacom dot de | Date: | Thu, 16 Dec 2004 15:57:45 +0000 |
| Subject: | #31126 [NEW]: Serious Bug in foreach | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-70371@lists.php.net to get a copy of this message | ||
From: rf at inmacom dot de
Operating system: Linux
PHP version: 4.3.10
PHP Bug Type: Arrays related
Bug description: Serious Bug in foreach
Description:
------------
Foreach gives an array instead of the value for each element of an array.
Reproduce code:
---------------
<?
$a = array( "21","22","23","24","25" );
var_dump( $a );
echo "<hr />";
foreach( $a as $v ) {
var_dump( $v );
echo "<hr />";
}
?>
Expected result:
----------------
array(5) {
[0]=>
string(2) "21"
[1]=>
string(2) "22"
[2]=>
string(2) "23"
[3]=>
string(2) "24"
[4]=>
string(2) "25"
}
<hr />string(2) "21"
<hr />string(2) "22"
<hr />string(2) "23"
<hr />string(2) "24"
<hr />string(2) "25"
<hr />
Actual result:
--------------
array(5) {
[0]=>
string(2) "21"
[1]=>
string(2) "22"
[2]=>
string(2) "23"
[3]=>
string(2) "24"
[4]=>
string(2) "25"
}
<hr />array(2) {
[0]=>
string(2) "21"
[1]=>
int(0)
}
<hr />array(2) {
[0]=>
string(2) "22"
[1]=>
int(1)
}
<hr />array(2) {
[0]=>
string(2) "23"
[1]=>
int(2)
}
<hr />array(2) {
[0]=>
string(2) "24"
[1]=>
int(3)
}
<hr />array(2) {
[0]=>
string(2) "25"
[1]=>
int(4)
}
<hr />
--
Edit bug report at http://bugs.php.net/?id=31126&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31126&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31126&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31126&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=31126&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=31126&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=31126&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=31126&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=31126&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=31126&r=support
Expected behavior: http://bugs.php.net/fix.php?id=31126&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=31126&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=31126&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=31126&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31126&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=31126&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=31126&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=31126&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=31126&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=31126&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=31126&r=mysqlcfg