ID:               24758
 User updated by:  vma1 at abv dot bg
 Reported By:      vma1 at abv dot bg
 Status:           Open
 Bug Type:         Arrays related
 Operating System: Slackware Linux 9.0
 PHP Version:      5CVS-2003-07-22 (dev)
 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------

[2003-07-22 18:17:59] vma1 at abv dot bg

No. It is still broken. But try my script exactly the way I've written
it. Your version works correctly, but not mine.

------------------------------------------------------------------------

[2003-07-22 16:53:43] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip

For me it works, so i think my latest commit fixed it.

$ php -r '$ar=array(0=>"a",1=>"b");foreach($ar as $k=>$v) echo
"$k=>$v\n";'
0=>a
1=>b

------------------------------------------------------------------------

[2003-07-22 16:33:19] 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



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=24758&edit=1

Reply via email to