Re: in_array() 4.0.0 -> 4.0.2

From: Date: Thu, 07 Sep 2000 18:16:25 +0000
Subject: Re: in_array() 4.0.0 -> 4.0.2
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-15761@lists.php.net to get a copy of this message
Rasmus, The purpose of in_array() is to say if an item is in the array, with a rather nice side effect of re-positioning the array pointer to that element. How are we to find the position of the element? I don't want to have to do an expensive for loop every time I want to get an index. Short of coding up a my_in_array() what are the alternatives? regards, David. ----- Original Message ----- From: Rasmus Lerdorf <rasmus@php.net> To: David Newcomb <davidn@vnvi.com> Cc: php-general <php-general@lists.php.net> Sent: Thursday, September 07, 2000 7:07 PM Subject: Re: [PHP] in_array() 4.0.0 -> 4.0.2 > > The functionality of in_array has changed between 4.0.0 -> 4.0.2 > > > > The difference is that in x.2 in_array() moves the internal array > > pointer to the found item; and in x.0 it dose not. > > > > Can anyone tell me why the change was made? And is the x.0 > > version a bug or is the x.2 version a bug? > > Hrm. I remember asking Andrei to change this. Although not exactly > this. What I didn't like was that if an element wasn't found in the > array, the array pointer ended up at the end of the array. He fixed that, > but I didn't realize that this also changed the nature of a match. The > question is whether or not in_array() should affect the array pointer at > all. I am not sure it should. > > -Rasmus >

« previous php.general (#15761) next »