#44180 [Opn->Bgs]: key in an array cannot be a reference in foreach loop
| From: | johannes@php.net | Date: | Wed, 20 Feb 2008 09:52:14 +0000 |
| Subject: | #44180 [Opn->Bgs]: key in an array cannot be a reference in foreach loop | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-122494@lists.php.net to get a copy of this message | ||
ID: 44180
Updated by: johannes@php.net
Reported By: martin dot koranda at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Feature/Change Request
Operating System: linux
PHP Version: 5.2.5
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
The array key is not to be changed afterwards - especially since an
array key can only be string or iteger and we can't really pevent the
write access to references.
Previous Comments:
------------------------------------------------------------------------
[2008-02-20 09:09:12] martin dot koranda at gmail dot com
Description:
------------
in foreach loop, if i try to use keys as a reference, i'll get "Fatal
error: Key element cannot be a reference". my question is why not? can
Zend developers add the possibility of key element reference in the
sixth PHP version??
Reproduce code:
---------------
foreach($arr as &$key => $val)
{
...
}
Expected result:
----------------
change keys inside the foreach loop
Actual result:
--------------
Fatal error: Key element cannot be a reference
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44180&edit=1