#16227 [Opn->Csd]: Using internal hash position is tricky.

From: Date: Tue, 17 Feb 2004 17:43:12 +0000
Subject: #16227 [Opn->Csd]: Using internal hash position is tricky.
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969358993@lists.php.net to get a copy of this message
ID: 16227 Updated by: irchtml@php.net Reported By: php dot net at alienbill dot com -Status: Open +Status: Closed Bug Type: Documentation problem Operating System: ANY PHP Version: Irrelevant New Comment: Closing this as yohgaki@php.net said the bug was fixed. Previous Comments: ------------------------------------------------------------------------ [2003-01-20 22:54:11] vdvo at vdvo dot net Well, so is it fixed or is it not? This bug's status is still Open. ------------------------------------------------------------------------ [2002-10-01 06:28:18] yohgaki@php.net FYI. The bug is fixed. Current CVS version does not swap internal hash position on assinment. ------------------------------------------------------------------------ [2002-10-01 06:13:17] yohgaki@php.net The issue is ZendEngine mess up hash position by assignment. I'll open new one for this. ------------------------------------------------------------------------ [2002-07-16 11:22:34] hholzgra@php.net each() as a function does not know in which context it was called so it just returns the 'current' element and advances the internal position pointer, very similar to the java next_element() iterator (hope i got the name right). when no more elements are left it returns false until being reset each() can not know that it was called from different loop runs so it will return false forever until reset. one might think about auto-reseting it after returning false once, but backwards compatibility will be in our way once again here the problem does not happen this way in java because there next_element() advances the internal pointer before returning values and you have to use first_element() to get the first one (which implies a reset) foreach uses a private copy of the array structure so it has its own internal pointer which is recreated for every foreach instance so the problem does occure here ------------------------------------------------------------------------ [2002-03-23 20:44:45] yohgaki@php.net Oops, $arr = array('a', 'b', 'c'); does reset position :) ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/16227 -- Edit this bug report at http://bugs.php.net/?id=16227&edit=1

« previous php.doc (#969358993) next »