#35835 [Opn->Csd]: next() does not work on referenced arrays
| From: | sniper@php.net | Date: | Thu, 29 Dec 2005 07:47:06 +0000 |
| Subject: | #35835 [Opn->Csd]: next() does not work on referenced arrays | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-91210@lists.php.net to get a copy of this message | ||
ID: 35835
Updated by: sniper@php.net
Reported By: ghetalion at ghetalion dot com
-Status: Open
+Status: Closed
Bug Type: Arrays related
Operating System: Windows XP
PHP Version: 4.4.1
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2005-12-29 06:39:24] judas dot iscariote at gmail dot com
this bug was reported dozens of time.
get :
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
and try again..
------------------------------------------------------------------------
[2005-12-29 04:57:20] flaming dot cows at gmail dot com
It works as expected (i.e. no bug) on 4.4.0 and 5.0.4 (bundled with
Zend IDE on win32 and *nix, as well as on Apache 2.0.54/PHP 5.0.5).
------------------------------------------------------------------------
[2005-12-29 04:41:33] ghetalion at ghetalion dot com
I always make some stupid mistake when posting on the internet....
echo &yup;
should be
echo $yup;
------------------------------------------------------------------------
[2005-12-29 04:39:34] ghetalion at ghetalion dot com
Description:
------------
When using next() on a referenced array, the internal pointer is not
moved at all.
Reproduce code:
---------------
function &getEach(&$a)
{
if(($elem = current($a)) !== FALSE)
{
$k = key($a);
next($a);
return $a[$k];
}
return false;
}
$alist = array("a", "b", "c");
for(reset($alist); $yup =& getEach($alist);)
{
echo &yup;
}
Expected result:
----------------
abc
Actual result:
--------------
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(etc)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35835&edit=1