Re: PHP 4.0 Bug #9794: array_keys resets the array pointer and can not be used when looping

From: Date: Fri, 16 Mar 2001 17:43:21 +0000
Subject: Re: PHP 4.0 Bug #9794: array_keys resets the array pointer and can not be used when looping
References: 1 2 3 4  Groups: php.dev 
Request: Send a blank email to php-dev+get-49091@lists.php.net to get a copy of this message
On Fri, Mar 16, 2001 at 11:21:39AM -0600, Andrei Zmievski wrote: > On Fri, 16 Mar 2001, Daniel Beckham wrote: > > Awesome. Are you planning to just fix the array_keys function, or will > > there be a change as to how the array functions work with the array > > pointers? > > It'll be on a case-by-case basis. Some functions do need to move the > pointers. It seems like this is a common problem, I think perhaps most of the PHP code (the C code) could be made cleaner if the Zend API separated pointers from the array structure. So that one could create a pointer and pass it as an argument to Zend hash functions, or something like that. It could be useful to have several pointers at once. One other option could be to have a pointer stack per hash, with two hash functions for pushing and popping the current pointer on/off the stack. A final option. It's easy for the C code using the Zend API to save the hash key for the element that the pointer currently points to. If there was a Zend function for setting the pointer (taking hash key as argument), it would be easier for the PHP C code to save and restore the pointer. Well, just some quick thoughts written down in a couple of minutes, there might be better alternatives, but I think one should consider some general ways of solving this problem. Stig

« previous php.dev (#49091) next »