Re: [PHP4BETA] in-array function

From: Date: Tue, 25 Apr 2000 13:14:54 +0000
Subject: Re: [PHP4BETA] in-array function
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-14059@lists.php.net to get a copy of this message
On Tue, 25 Apr 2000, Andreas Pour wrote: > > Hi, > > Any chance the in_array function can be modified to return the key > instead of a boolean, perhaps if a third argument were added to ask for > that info? Often I like to delete an entry from the array or do > something else with it, or use it as a reverse lookup, and as is the > function does not help very much. Use array_keys($array, "value") to search for the keys that correspond to that value in the array. > As long as we are on the topic, could it also be possible to pass a > Regex as the needle? Yes, it might be possible to add this as an option to preg_grep(). -Andrei * The best source is the source code. *

« previous php.version4 (#14059) next »