|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-07-22 16:33 UTC] vma1 at abv dot bg
Description:
------------
The last CVS version php5-200307221730 has broken handling of arrays in foreach() structure. When enumerating array keys the values cannot be accessed.
Reproduce code:
---------------
$list = array ();
$list ["0"] = "abc";
foreach ($list as $key => $unused) {
printf ("%s<br>", $list [$key]);
}
Expected result:
----------------
abc
Actual result:
--------------
Notice: Undefined index: 0 in /usr/local/apache/site/htdocs/bug.php on line 5
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 20 21:00:02 2025 UTC |
Actually very small changes in the script make the problem go away. E.g. change index from "0" to 0, or replace printf with echo, or change array initialization from $list = array ();$list ["0"] = "abc"; to $list = array ("0" => "abc"); and the problem goes away.