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

From: Date: Mon, 19 Feb 2001 18:05:37 +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  Groups: php.dev 
Request: Send a blank email to php-dev+get-46938@lists.php.net to get a copy of this message
I agree, That way we don't duplicate code, and we don't have different behavior.. Ill work on this sometime today -Jason ----- Original Message ----- From: "Andrei Zmievski" <andrei@ispi.net> To: "Jason Greene" <jason@inetgurus.net> Cc: "André Langhorst" <andre@php.net>; "PHP Development" <php-dev@lists.php.net> Sent: Monday, February 19, 2001 12:02 PM Subject: Re: [PHP-DEV] PHP 4.0 Bug #9337 Updated: make in_array return key, if searched value was found > On Mon, 19 Feb 2001, Jason Greene wrote: > > > We can change in_array() to return the the key if it's found, and false > > > if it's not, but imagine all the scripts it would break.. > > about 1/4th of mine : ) > > > > Well I think the basic problem is that people are using in_array against its intention. > > It is a Boolean function, and that really shouldn't be changed. We could create > > another > > function that is more designed for searching? perhaps array_find? I wouldn't mind > > spending time on this if agreed upon. > > Could be done. The way I'd do it is have one php_in_array() C function > that gets parameters passed through from in_array() and array_find() as > well as a flag indicating whether to just return true/false or the > actual key. > > -Andrei > > "The human brain is a wonderful thing. It starts working the moment you > are born, and never stops until you stand up to speak in public. " -- Sir > George Jessel > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net > For additional commands, e-mail: php-dev-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.dev (#46938) next »