Re: PHP 4.0 Bug #9337 Updated: make in_array return key, if searched value was found

From: Date: Tue, 20 Feb 2001 14:44:10 +0000
Subject: Re: PHP 4.0 Bug #9337 Updated: make in_array return key, if searched value was found
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.dev 
Request: Send a blank email to php-dev+get-47064@lists.php.net to get a copy of this message
On Tue, Feb 20, 2001 at 08:27:59AM -0600, Andrei Zmievski wrote: > in_array() used to move the pointer to the entry found, but people > complained about it so I remove it... :) And I thought it was neat, can't please everyone I guess (: There seems to be a general problem with array functions and people that want the pointer to be preserved. Rather than making functions always do this (which makes them slower and is generally a pain) or adding extra options to a lot of functions, how about a function for setting the pointer? I could in order to save the position do $key = key($arr). To restore it later, I could then do something like array_setpos($key). I'm not sure if the Zend API allows for setting the position without looping through the array though. If array_setpos() is passed a non- existing key it should return FALSE, else TRUE. What do you think? Stig

« previous php.dev (#47064) next »