Re: in_array() 4.0.0 -> 4.0.2

From: Date: Tue, 12 Sep 2000 13:57:57 +0000
Subject: Re: in_array() 4.0.0 -> 4.0.2
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-16357@lists.php.net to get a copy of this message
On Tue, 12 Sep 2000, David Newcomb wrote: > I have done some profiling on some of my code and found that in_array > is an expensive operation. Heaven only knows how heavy my_in_array() > must be! > > > on the other hand I have not yet been in a situation > > where I was worried about moving the pointer by in_array. > > I must say that I'm with Andrei Zmievski on this one. I have not come > across a situration which I have used next(),current(),prev() or any > other function that moves the internal array pointer (except in_array() ;) > > > > Of course, using the configurable approach, there could be an optional > > third argument for "don't move the pointer". > > This will be a forth option! Although not published in the > documentation, there has been added a boolean "strict" parameter > to make the in_array() comparison more strict. Here is the reference: > > In php-4.0.2/ext/standard/array.c line 1036 > /* {{{ proto bool in_array(mixed needle, array haystack [, bool strict]) > Checks if the given value exists in the array */ > PHP_FUNCTION(in_array) > { I can add the fourth option, no problem. You just have to ask yourself if that's what you really want and whether array pointer movement should be on by default or not. -Andrei As I was going up the stair, I met a man who wasn't there. He wasn't there again today. I wish, I wish he'd stay away. -Hughes Mearns

« previous php.general (#16357) next »